Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Arrays  RSS feed

 
albert lekaj
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me how to request values from the user for an array,that how long the array will be and the user to fill it with any kind of values(ex. int,double or String)
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a lot of different things there. What have you tried so far, and what specifically (one thing at at time) are you having trouble with?

For instance, from reading that, I might guess that you don't know how to get user input, so I might direct you to google for java IO tutorial. Or I might guess that you don't know anything about arrays, so I might suggest you google for java array tutorial.
 
Badal Chowdhary
Ranch Hand
Posts: 34
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Albert,

The main program of Java takes a String array:


So if your class name is TakeParams.java, you can run it as below to take 2 String params:
java TakeParams string1 string2

To convert it to other data type, you can use parse method. Eg: parseDouble, parseInt...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!