Results 1 to 4 of 4
Thread: repetition of 'arguments'(?)
- 12-12-2007, 10:56 AM #1
Member
- Join Date
- Dec 2007
- Posts
- 3
- Rep Power
- 0
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,
- 12-12-2007, 01:51 PM #2
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.
- 12-13-2007, 06:29 AM #3
Member
- Join Date
- Dec 2007
- Posts
- 26
- Rep Power
- 0
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.
- 12-13-2007, 10:08 AM #4
Senior Member
- Join Date
- Nov 2007
- Location
- Newport, WA
- Posts
- 141
- Rep Power
- 0
Yeah, eclipse wont like this because you have a * in the declaration name.Eclipse (which I'm working in) doesn't really seem to like:
System.out.println("User " + ret.name* + ret.place*);
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
-
Arguments in Main
By CyberFrog in forum New To JavaReplies: 2Last Post: 03-30-2008, 09:37 PM -
Finding arguments of Servlet
By Java Tip in forum Java TipReplies: 0Last Post: 01-25-2008, 07:04 PM -
Printing command line arguments
By Java Tip in forum Java TipReplies: 0Last Post: 12-03-2007, 09:27 AM -
Variable No. of Arguments
By Gajesh Tripathi in forum New To JavaReplies: 2Last Post: 10-31-2007, 02:50 PM -
Java Command Line Arguments In Eclipse IDE
By JavaForums in forum EclipseReplies: 0Last Post: 05-19-2007, 09:45 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks