Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes Need Help for an Array. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need Help for an Array." Watch "Need Help for an Array." New topic
Author

Need Help for an Array.

Muzafar Ali
Ranch Hand

Joined: Jun 11, 2009
Posts: 34
Hey guys,
i need help to set data in Array, in this program i set values for names from 1 upto 5 , actually i want that values to be entered by using scanner class then retrieved anytime.



~When You Learn Anything, Learn by Heart !
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Did you check out the Scanner API docs? It has samples of how to use the Scanner class.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Muzafar Ali
Ranch Hand

Joined: Jun 11, 2009
Posts: 34
Maneesh Godbole wrote:Did you check out the Scanner API docs? It has samples of how to use the Scanner class.



Thanks for reply,
i not checked that docs ever but i will check,
One question i think my problem was not about scanner you know.
i have used scanner class i can get input using Scanner with any data type
my question was
how to get input from scanner to set values in Array;
then retrieve them.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37988
    
  22
Why are you using the for loop to look for the number? You don't need a number array at all. You can enter a number, calculate the index, and display the name with only one array.
Muzafar Ali
Ranch Hand

Joined: Jun 11, 2009
Posts: 34
Campbell Ritchie wrote:Why are you using the for loop to look for the number? You don't need a number array at all. You can enter a number, calculate the index, and display the name with only one array.


Thanks for you reply
i will try to do that.
Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 273

Muzafar Ali wrote:how to get input from scanner to set values in Array;
then retrieve them.

Use java.util.ArrayList. It's like an array, but it doesn't have a fixed size, so you can add as many Strings to it as you want


SCJP 6 || SCWCD 5
Muzafar Ali
Ranch Hand

Joined: Jun 11, 2009
Posts: 34
Michael Angstadt wrote:
Muzafar Ali wrote:how to get input from scanner to set values in Array;
then retrieve them.

Use java.util.ArrayList. It's like an array, but it doesn't have a fixed size, so you can add as many Strings to it as you want

Thanks fo reply,
can you post a sample for that?
Jon Kho
Ranch Hand

Joined: Jun 03, 2009
Posts: 54


do use "www.google.com" or any other search engines because it has many examples on array list..
Muzafar Ali
Ranch Hand

Joined: Jun 11, 2009
Posts: 34
Jon Kho wrote:

do use "www.google.com" or any other search engines because it has many examples on array list..


Thanks for your answer,
i will try to find those by using search engine thanks for help friends.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need Help for an Array.
 
Similar Threads
program that prints the multiplication table up to one
concurrency error
Need Help Creating A Loop!
diamond pattern without parse.int (Someone help me T.T) :cry:
Why is my type unexpected? required variable found value