473,320 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help with using Arrays

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
4 1631
r035198x
13,262 8TB
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
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
r035198x
13,262 8TB
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
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

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

Similar topics

10
by: Sims | last post by:
Hi I have a table with something like ID PARENT 0 | -1 1 | -1 2 | 1 3 | 1
31
by: da Vinci | last post by:
OK, this has got to be a simple one and yet I cannot find the answer in my textbook. How can I get a simple pause after an output line, that simply waits for any key to be pressed to move on? ...
41
by: Psykarrd | last post by:
I am trying to declare a string variable as an array of char's. the code looks like this. char name; then when i try to use the variable it dosn't work, however i am not sure you can use it...
4
by: CoolPint | last post by:
I would be grateful if someone could point out if I am understanding correctly and suggest ways to improve. Sorry for the long message and I hope you will kindly bear with it. I have to make it...
4
by: Mingus Tsai | last post by:
Hello- please help with unpickling problem: I am using Python version 2.3.4 with IDLE version 1.0.3 on a Windows XPhome system. My problem is with using cPickle to deserialize my pickled...
8
by: inkexit | last post by:
I am a very amatuer c++ programmer and a somewhat accomplished composer. I am trying to write some code that creates 'self similar' melodies from a base melody the user inputs. This musical idea...
1
by: Geoff | last post by:
I was wondering if anyone could help me with a problem I am having. I am trying to read in a list of numbers from a file and then sort them using pointers and malloc() and free(). I know how to...
8
by: hothead098 | last post by:
ASSIGNMENT (4) USING AND MANIPUPATING ARRAYS (Chapter 10 material) For this assignment you are to: 1) Create and manage arrays a) One of type integers (containing 10 elements). b) One of...
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
2
by: Dr Dav | last post by:
Hello all, I'm a physicist whose rewriting a numerical simulation, previously written in IDL, in C with the goal reducing runtime. As you may imagine, my C programming skills are quite poor but I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.