Results 1 to 9 of 9
  1. #1
    edelric666 is offline Member
    Join Date
    Oct 2010
    Posts
    12
    Rep Power
    0

    Default "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.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,955
    Rep Power
    8

    Default

    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

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    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.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,229
    Rep Power
    19

    Default

    i havent written this very small paper
    Then why are you asking members here to read it?

    db

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,229
    Rep Power
    19

    Default

    if you see any spelling or grammer mistakes please let me know
    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".

    db

  6. #6
    edelric666 is offline Member
    Join Date
    Oct 2010
    Posts
    12
    Rep Power
    0

    Default

    Quote Originally Posted by Darryl.Burke View Post
    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".

    db
    yeah thanks for that, because everyone types essays and casual forums in the same way...

  7. #7
    edelric666 is offline Member
    Join Date
    Oct 2010
    Posts
    12
    Rep Power
    0

    Default

    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?”.

  8. #8
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    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 ;)

  9. #9
    edelric666 is offline Member
    Join Date
    Oct 2010
    Posts
    12
    Rep Power
    0

    Default

    thanks mate, added the comment to the actual program like this


    import javax.swing.*;
    class Howareyou// note here that methods are the behaviours of classes as opposed to the whole program.


    you reckon thats better? i also made the changes elsewhere.

Similar Threads

  1. what does it mean "pass an argument to a method"
    By edelric666 in forum New To Java
    Replies: 6
    Last Post: 10-31-2010, 11:08 AM
  2. pass "." as a string
    By billq in forum New To Java
    Replies: 5
    Last Post: 02-07-2010, 05:39 AM
  3. problem with argument list and precedence "(" and ")"
    By helpisontheway in forum Advanced Java
    Replies: 6
    Last Post: 12-24-2009, 07:50 AM
  4. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •