Results 1 to 4 of 4
  1. #1
    Igor is offline Member
    Join Date
    Dec 2007
    Posts
    3
    Rep Power
    0

    Default repetition of 'arguments'(?)

    Hi all,

    I'm really new to java and have a heap of code that I'm now trying to get acquinted with. Don't know if this is the right place to post this question, but here it is:

    System.out.println("User " + ret.name + ret.place);
    Which is a line of the code. Not important right now what it does or why, but suppose I want to allow the program to retrieve (which I say "ret." means right?) possibly more than one name/place for a user.
    Eclipse (which I'm working in) doesn't really seem to like:
    System.out.println("User " + ret.name* + ret.place*);

    Can anyone tell me if there is a possibily to do this the above way (and that it's just some incorrect syntax), or that something like that won't work at all and I'll have to find a solution somewhere else in the program.

    thanks,

  2. #2
    ShoeNinja's Avatar
    ShoeNinja is offline Senior Member
    Join Date
    Oct 2007
    Posts
    124
    Rep Power
    0

    Default

    No it's not possible to do it that way. It's much more than bad syntax.

    In your code, ret is an object (instance of a class). It represents a single instance. The .name and the .place are methods in whatever class to which ret belongs.

    It sounds like you need to do some reading on the idea of classes, objects and methods before you try to start learning too much more code.

  3. #3
    apfroggy0408 is offline Member
    Join Date
    Dec 2007
    Posts
    26
    Rep Power
    0

    Default

    If I'm thinking what you're trying to do correctly is you typing in the information and it showing up?

    If so, set it up where you have those two variables set up to be the input of whatever the keyboard puts.

    You'll have to be familiar with the Scanner class.

  4. #4
    staykovmarin is offline Senior Member
    Join Date
    Nov 2007
    Location
    Newport, WA
    Posts
    141
    Rep Power
    0

    Default

    Eclipse (which I'm working in) doesn't really seem to like:
    System.out.println("User " + ret.name* + ret.place*);
    Yeah, eclipse wont like this because you have a * in the declaration name.

    Three notes:
    First of all, its not Eclipse the doesnt like it, its java that doesnt like it. Learn to separate the two.
    Second. FOR GODS SAKE? Why are you using an IDE? If you know as little java as you seem to, you should not even be touching eclipse for the next few months. You are missing very important concepts.
    Third. Its nice when you define what "it doesnt like this" means... i have never had an error "Line 34: i dont like this".

Similar Threads

  1. Arguments in Main
    By CyberFrog in forum New To Java
    Replies: 2
    Last Post: 03-30-2008, 10:37 PM
  2. Finding arguments of Servlet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-25-2008, 08:04 PM
  3. Printing command line arguments
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-03-2007, 10:27 AM
  4. Variable No. of Arguments
    By Gajesh Tripathi in forum New To Java
    Replies: 2
    Last Post: 10-31-2007, 03:50 PM
  5. Java Command Line Arguments In Eclipse IDE
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 05-19-2007, 10:45 AM

Posting Permissions

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