File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

array question?

 
Rayt Leeop
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have several questions as follows and will appreciate any one can help.

1. I need to read data from text file and strore them in an array. It is a name game from SSA. Here is the text file. I need to read them and then store in an array. The number is the ranking of the name in the 1990, 1920, 1930...
Samuel 31 41 46 60 61 71 83 61 52 35 28 Sandi 0 0 0 0 704 864 621 695 0 0 0 Sandra 0 942 606 50 6 12 11 39 94 168 257
...

I wrote the following to read the file:



But how can I create an array to store the 11 numbers?


And also I need to pass the line of text into the constructor, how can I do it? Many suggestions
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rayt Leeop wrote:
But how can I create an array to store the 11 numbers?

Object[] values = new Object[11];
Rayt Leeop wrote:
And also I need to pass the line of text into the constructor, how can I do it? Many suggestions

I am not getting you here.
frankly, clarity is missing in your description/question!
 
Rayt Leeop
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks. This will create 11 number. But how can I store those number to the array since there are many data in the text file. Many thanks.




Seetharaman Venkatasamy wrote:
Rayt Leeop wrote:
But how can I create an array to store the 11 numbers?

Object[] values = new Object[11];
Rayt Leeop wrote:
And also I need to pass the line of text into the constructor, how can I do it? Many suggestions

I am not getting you here.
frankly, clarity is missing in your description/question!
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rayt Leeop wrote:This will create 11 number. But how can I store those number to the array since there are many data in the text file. Many thanks.

As I told in my previous post, still the clarity is missing! please can you explain well about your requirement?
 
Ogeh Ikem
Ranch Hand
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this. The following code creates a 2 dimensional array i.e. an array of int arrays, converts each line in the text file into an int array and adds the int array into the array of int arrays.

>
 
Rayt Leeop
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried that code but the Eclipse siad Name() at the main mehtod is not type errror. Any suggestion?
I am doing a exercise similar to this: http://www.cs.utexas.edu/~scottm/cs307/Assignments/BabyNames.html

any helps? Many thanks
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic