Results 1 to 9 of 9
- 11-04-2010, 07:39 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 12
- Rep Power
- 0
"pass argument:what does it mean?" can you pls read and give me some feedback
hey guys i have written this very small paper aimed at a beginner programmer. what is meant to do is make a novice be able to understand what it mean to pass a arguement to a method. if you have a read and just give me a bit of feedback it would be very helpful. please if you see any spelling or grammar mistakes please let me know also. its only one page, so it shouldnt take you more than 10 mins =) thanks to anyone who does. i have uploaded it to sendspace, its really sall in size. if you want i can post it straight on here.
heres the file Download What does it mean to pass an argument to a method.docx from Sendspace.com - send big files the easy way
EDIT: im posting it here directly
What does it mean to pass an argument to a method?
To be able to understand what it means to pass an argument to a method, first it must be known what arguments and methods actually are.
A method can be thought of in a variety of ways. In everyday life situations “methods” can be seen everywhere. One way to think about it is in televisions. If you think of a method as “what a program can do” then to call a method is to give an instruction. In the case of Televisions it has methods for how high the volume is, what channel to play etc. When a channel is selected, the number on which it is situated tells the TV which channel to play. The number is therefore an argument and so selecting the number is passing the argument. From this it can be seen that a method is what a program can do, and an argument is the actual value that is passed in when the method is called. 1
Now if thought about in programming terms, using the following example, it can be explained what passing an argument to a method means. Here is a very simple program.
import javax.swing.*;
class Howareyou
{
public static void main (String[] param)
{
Question();
System.exit(0);
}
public static void Question()
{
System.out.println("Hello there, how are you?");
} // ends question
} // ends class Howareyou
In this case the method, System.out.println is an instruction to print something to the console, and it has been given the parameter of “string” by the line,(String[] param). However as a method this is only what the program can do. It doesn’t give it anything to actually print. That is provided by the argument, which comes after the method in the brackets.
In the above example we can see that to pass an argument is to call a method with parameters that need to be given values. Passing the argument is taking what is inside the brackets (“Hello there, how are you?) And giving it to the instruction, System.out.println as what to do. Therefore if the example was actually run it would print the words “Hello there, how are you?”.Last edited by edelric666; 11-04-2010 at 09:20 PM.
- 11-04-2010, 07:44 PM #2
I'm too lazy to click that, or download a file, or open said file, or read it, but I will throw this out there:
The most helpful-to-newbies description of passing arguments I've ever seen is JavaRanch Campfire - Cup Size: a Story About Variables and its follow up, JavaRanch Campfire - Pass By Value, Please
- 11-04-2010, 08:01 PM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,560
- Rep Power
- 11
I'm trapped behind a proxy server and can't access your document. If it's a reasonable length you could post it here.
Various people here participated in your threads on this subject - just a thought, but your ideas could have been given as part of those discussions.
- 11-04-2010, 08:18 PM #4
Then why are you asking members here to read it?i havent written this very small paper
db
- 11-04-2010, 08:20 PM #5
If it's anything like your post here, you need to change the first letter of every sentence and the first person singular to uppercase. And use a spell checker, ther's no such word a "grammer".if you see any spelling or grammer mistakes please let me know
db
- 11-04-2010, 08:46 PM #6
Member
- Join Date
- Oct 2010
- Posts
- 12
- Rep Power
- 0
- 11-04-2010, 08:47 PM #7
Member
- Join Date
- Oct 2010
- Posts
- 12
- Rep Power
- 0
hopefully this doesnt count as too long...
What does it mean to pass an argument to a method?
To be able to understand what it means to pass an argument to a method, first it must be known what arguments and methods actually are.
A method can be thought of in a variety of ways. In everyday life situations “methods” can be seen everywhere. One way to think about it is in televisions. If you think of a method as “what a program can do” then to call a method is to give an instruction. In the case of Televisions it has methods for how high the volume is, what channel to play etc. When a channel is selected, the number on which it is situated tells the TV which channel to play. The number is therefore an argument and so selecting the number is passing the argument. From this it can be seen that a method is what a program can do, and an argument is the actual value that is passed in when the method is called. 1
Now if thought about in programming terms, using the following example, it can be explained what passing an argument to a method means. Here is a very simple program.
import javax.swing.*;
class Howareyou
{
public static void main (String[] param)
{
Question();
System.exit(0);
}
public static void Question()
{
System.out.println("Hello there, how are you?");
} // ends question
} // ends class Howareyou
In this case the method, System.out.println is an instruction to print something to the console, and it has been given the parameter of “string” by the line,(String[] param). However as a method this is only what the program can do. It doesn’t give it anything to actually print. That is provided by the argument, which comes after the method in the brackets.
In the above example we can see that to pass an argument is to call a method with parameters that need to be given values. Passing the argument is taking what is inside the brackets (“Hello there, how are you?) And giving it to the instruction, System.out.println as what to do. Therefore if the example was actually run it would print the words “Hello there, how are you?”.
- 11-04-2010, 10:25 PM #8
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,560
- Rep Power
- 11
In terms of Java you could highlight the fact that methods are the behaviour of instances of a class, rather than a program as a whole.
"If you think of a method as “what a program can do” then to call a method is..." could be "If you think of a method as “what a thing can do” then to call a method is..."
"However as a method this is only what the program can do. It doesn’t give it anything to actually print. That is provided by the argument, which..." could be "However as a method this is only what a print stream can do (System.out is a print stream). It doesn’t give it anything to actually print. That is provided by the argument, which..."
But that's just a little change of emphasis.
I'm glad to see my radio (methods-as-behaviour, calling-as-commanding) metaphor put to use ;)
- 11-04-2010, 11:03 PM #9
Member
- Join Date
- Oct 2010
- Posts
- 12
- Rep Power
- 0
Similar Threads
-
what does it mean "pass an argument to a method"
By edelric666 in forum New To JavaReplies: 6Last Post: 10-31-2010, 11:08 AM -
pass "." as a string
By billq in forum New To JavaReplies: 5Last Post: 02-07-2010, 05:39 AM -
problem with argument list and precedence "(" and ")"
By helpisontheway in forum Advanced JavaReplies: 6Last Post: 12-24-2009, 07:50 AM -
MoneyOut.println("It took you (whats wrong?>",year,"<WW?) years to repay the loan")
By soc86 in forum New To JavaReplies: 2Last Post: 01-24-2009, 06:56 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks