Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 java help
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mendem03




PostPosted: Fri May 21, 2010 3:32 pm   Post subject: java help

i am new to java and i want to kow if you can give 1 variable multiply values were the user is not entering any of the values.
I know about arrays and they let the user enter multiply values but i dont know if i can put multiply values myself in the program
Sponsor
Sponsor
Sponsor
sponsor
TheGuardian001




PostPosted: Fri May 21, 2010 3:55 pm   Post subject: Re: java help

Um... What are you asking here? If you can store more than one value in a variable?

If it's an array, yes, you can. Java doesn't care where the information you store in variables comes from. Whether you read it from a file, get it from the user, or put it directly into the program doesn't matter.

For example:
Java:

int[] myNumbers = new int[10];

myNumbers[1] = 2;
myNumbers[6] = 12;
mendem03




PostPosted: Fri May 21, 2010 4:35 pm   Post subject: Re: java help

Ya but i want to put it in a system.out.println command will it work in there
TheGuardian001




PostPosted: Fri May 21, 2010 6:01 pm   Post subject: Re: java help

Um... Yes. Again, Java doesn't care where the data is coming from. To the JRE, there is absolutely no difference between data you program into your source code, get from the user, read from a file, etc.

System.out.println(varName[2]);

will output the third element of the array varName, regardless of how the value got put in that location.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: