By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,782 Members | 1,154 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,782 IT Pros & Developers. It's quick & easy.

Help with using Arrays

P: 3
Hello world. I am new to JAVA and need help developing a program in which one can enter names from the keyboard and output those names in alphabetical order. Im thinking it involves arrays but i really dont have good undrstanding or much experience with the program.
Jan 10 '07 #1
Share this Question
Share on Google+
4 Replies


10K+
P: 13,264
Hello world. I am new to JAVA and need help developing a program in which one can enter names from the keyboard and output those names in alphabetical order. Im thinking it involves arrays but i really dont have good undrstanding or much experience with the program.
If you want to use an array then you need the user to enter the number of names they are going to enter first. Do you know how to take input from the user into a program?
Jan 11 '07 #2

P: 3
If you want to use an array then you need the user to enter the number of names they are going to enter first. Do you know how to take input from the user into a program?

i think. would you first use something like this to get the number of names

System.out.print("How many names would you like to enter:");
amount = console.readLine();
temp= Integer.parselnt(amount)

how do you get the program to know how many to expect.and would i use the same format to take input for the names. i know i would have to replace integer on the third line with a code to read words.
Jan 11 '07 #3

10K+
P: 13,264
i think. would you first use something like this to get the number of names

System.out.print("How many names would you like to enter:");
amount = console.readLine();
temp= Integer.parselnt(amount)

how do you get the program to know how many to expect.and would i use the same format to take input for the names. i know i would have to replace integer on the third line with a code to read words.
You've got it.

Now you declare the array as
Expand|Select|Wrap|Line Numbers
  1.  String[] names = new String[temp]; 
and use a loop to take all the names and put them into the array.
Jan 11 '07 #4

P: 3
You've got it.

Now you declare the array as
Expand|Select|Wrap|Line Numbers
  1.  String[] names = new String[temp]; 
and use a loop to take all the names and put them into the array.

ok. i will get back to you as soon as I run into any other problems. THANKS
Jan 11 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.