Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Java Help

Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-21-2006, 02:39 PM
Sionofdarkness Sionofdarkness is offline
Programming Expert
 
Join Date: Jul 2006
Posts: 385
Rep Power: 10
Sionofdarkness is on a distinguished road
Default Arguments

What are arguments? I'm pretty sure that every programming language has arguments (right?) but what are they? Are they a specific kind of function, or is it a term that covers a lot of functions?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-21-2006, 04:50 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 2,034
Last Blog:
NaNoWriMo Day 23 The...
Rep Power: 24
WingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the rough
Default

An argument is a piece of information that you give to a function to work with. Depending on the argument passed, it may or may not be changed by the function.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-22-2006, 11:35 AM
Sionofdarkness Sionofdarkness is offline
Programming Expert
 
Join Date: Jul 2006
Posts: 385
Rep Power: 10
Sionofdarkness is on a distinguished road
Default

So could you pass an argument through a lot of functions, and only some of the functions would affect it, while others would not? For some reasons, this reminds me of a catalyst, although it is very different from one.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-23-2006, 09:39 AM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 2,034
Last Blog:
NaNoWriMo Day 23 The...
Rep Power: 24
WingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the rough
Default

If you have nested function calls, and each one passes it on to the next in the function call, yes. However, you would probably need to send it as changeable all the way down, even if some of the functions don't change it.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-29-2006, 12:20 PM
Sionofdarkness Sionofdarkness is offline
Programming Expert
 
Join Date: Jul 2006
Posts: 385
Rep Power: 10
Sionofdarkness is on a distinguished road
Default

Now I'm a little more confused. I think I'll just stay away from this topic for awhile.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 07-29-2006, 02:45 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 2,034
Last Blog:
NaNoWriMo Day 23 The...
Rep Power: 24
WingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the rough
Default

Are you familiar with how functions work?
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 08-21-2006, 02:20 PM
Sionofdarkness Sionofdarkness is offline
Programming Expert
 
Join Date: Jul 2006
Posts: 385
Rep Power: 10
Sionofdarkness is on a distinguished road
Default

A little. How about giving me one of those examples? Those always seem to help a lot.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 08-21-2006, 02:38 PM
amac amac is offline
Newbie
 
Join Date: Aug 2006
Posts: 8
Rep Power: 0
amac is on a distinguished road
Default

Quote:
Originally Posted by Sionofdarkness View Post
A little. How about giving me one of those examples? Those always seem to help a lot.
Arguments are what you give to functions. For example

Code:
void printFunction(String argument){
 System.out.println(argument);
}
This is a method which prints out the argument. To call it, another method would have the following code:

Code:
String data = "hello world";
printFunction(data);
Here you can see that the code passes in a string that contains "hello world", meaning that when the printFunction method is executed argument="hello world".

The talk of nested function calls isn't really important. it would just be, for example, printFunction having the following code:
Code:
void printFunction(String argument){
 
  printWord(argument);
}
In that case the printFunction function is called, and it in turn calls another function 'printWord' with its own argument. So it passes "hello world" onto printWord.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 08-23-2006, 09:28 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 2,034
Last Blog:
NaNoWriMo Day 23 The...
Rep Power: 24
WingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the rough
Default

Functions in programming work a lot like they do in math, except programming functions get better names that f() or g().

In math, when you say f(x) = 2x, you are defining a rule: for input x, output 2 times x. In programming you have the same idea, except it can be more complicated. Because we have various data types (float, int, etc) you need to be precise about the input and output when you define your function. Also, they can do a lot more complicated stuff.

Code:
float f(float x)
{
  float temp;
  temp = 2*x;
  return temp;
}
This programming function f does the same as the math function.

-----

If we look at g(x) = 2 sqrt(x), things get more complicated.
Code:
float g(float x)
{
  float temp;
  temp = 2*sqrt(x);
  return temp;
}

float sqrt(float x)
{
  // do something
}
Notice how x gets passed into g, which has to hand it off to sqrt. This chain can happen for multiple levels, one function calling another calling another. If, at any point, one of them says "I'm not allowed to change x", then any changes that functions it calls try to make will be cancelled out when it refuses to pass those changes back.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Arguments in Perl smith Perl 3 06-08-2007 09:39 PM
Build Arguments Chan C# Programming 1 05-03-2007 11:53 AM


All times are GMT -5. The time now is 04:11 PM.

Contest Stats

John ........ 223.00000
dargueta ........ 168.00000
Xav ........ 164.00000
gaylo565 ........ 18.00000
WingedPanther ........ 15.00000
|pH| ........ 15.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 65%

Ads