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.
Help with using Arrays
Collapse
X
-
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?Originally posted by JoeMugsyHello 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. -
Originally posted by r035198xIf 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.prin t("How many names would you like to enter:");
amount = console.readLin e();
temp= Integer.parseln t(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.Comment
-
You've got it.Originally posted by JoeMugsyi think. would you first use something like this to get the number of names
System.out.prin t("How many names would you like to enter:");
amount = console.readLin e();
temp= Integer.parseln t(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.
Now you declare the array as
and use a loop to take all the names and put them into the array.Code:String[] names = new String[temp];
Comment
Comment