The Artima Developer Community
Sponsored Link

Java Answers Forum
Text File Data ---> Array

1 reply on 1 page. Most recent reply: May 2, 2002 11:53 AM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Eric Hoffheiser

Posts: 2
Nickname: caalis
Registered: May, 2002

Text File Data ---> Array Posted: May 2, 2002 2:17 AM
Reply to this message Reply
Advertisement
Can anyone tell me a way (or the best way) to put data read from a text file into an array? In the text file, I've got String variables and int variables and I'm having a problem assigning my int values to their instance variable counterparts in my support class, called Student. I've made a new Student object:

Student x = new Student();

but when I try doing x.setWhatever for the int variables, I get the message:
"setWhatever(int) in Student cannot be applied to (java.lang.String)"

I've got to make a Student object to store in each index of the array, so I have to have String and int values in that object. I can send more code if that would help. Thanks.


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Text File Data ---> Array Posted: May 2, 2002 11:53 AM
Reply to this message Reply
As you said, you have a text file, therefore, there are no integers in it. What it does have is text, or strings that can perhaps be parsed into integers (and maybe other things). To parse an integer value from a String, you can use Integer.parseInt( String ).

Flat View: This topic has 1 reply on 1 page
Topic: JTree & Popup Menu Previous Topic   Next Topic Topic: Passing applet variables to html document

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use