Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    Calgary, AB
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing String messages in Java

    How can I pass a string message to another method?

  2. #2
    New Coder
    Join Date
    Nov 2004
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts
    By message are you referring to the soap technology or a you just referring to a string?

  3. #3
    Regular Coder
    Join Date
    Sep 2002
    Location
    Calgary, AB
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I want to say something like

    String message;

    message = "Hello";

    Then pass that message to another method so I could use it in another method like so:

    System.out.println (message);




    Thanks,
    Nick!

  4. #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    define your method so that is accepts a String as an argument, then you can use it in your message:

    public void useTheMessage(String mess){
    System.out.println(mess);
    }

    then you can do:
    useTheMessage("Any message you want to sop");
    I am the luckiest man in the world

  5. #5
    Regular Coder
    Join Date
    Mar 2004
    Location
    Norway
    Posts
    204
    Thanks
    0
    Thanked 0 Times in 0 Posts
    like this?:
    Code:
    .....
     printTest("texttoprint");
    ....
    ....
    void printTest(String text)
    {
        System.out.println(text);
    }
    Edit: Didn't see your post Rolf...
    <JPM />

  6. #6
    Regular Coder
    Join Date
    Sep 2002
    Location
    Calgary, AB
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank You!


 

Posting Permissions

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