Two Laptop Bag*
The moose likes Beginning Java and the fly likes storing user input in an array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "storing user input in an array" Watch "storing user input in an array" New topic
Author

storing user input in an array

Katie Tuffrey
Greenhorn

Joined: Dec 14, 2011
Posts: 6
so i have a few classes:
GuiMain
StudentProfileDisplayGui
StudentProfileEditGui
Students

im not sure the best way to go about creating my array...
i want to store input that the user enters in the StudentProfileEditGui into an array, either in the student class or in the StudentProfileEditGui.

i know how an array works + the basic syntax but really not sure how to go about it, ive tried it in my StudentProfileEditGui and it throws up numerous errors.


this is my students class:


i will post my other if needed
x
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Katie Tuffrey wrote:...ive tried it in my StudentProfileEditGui and it throws up numerous errors...

Please post what you've tried and the errors you encountered.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7892
    
  21

Katie Tuffrey wrote:im not sure the best way to go about creating my array...
i want to store input that the user enters in the StudentProfileEditGui into an array, either in the student class...

No.
And the class you've created is called 'Students' even though it only seems to define a specific Student.

...or in the StudentProfileEditGui.

Definitely not. Keep your GUI completely separate from your data objects.

Try this: Student (in place of your 'Students') for an individual; Students (or possibly a StudentManager) to handle bunches of students; and StudentProfileEditGui (and any other GUI object you think you need) for your GUI stuff.

i know how an array works + the basic syntax but really not sure how to go about it, ive tried it in my StudentProfileEditGui and it throws up numerous errors.

My advice: forget arrays, and learn the Java collections API. An ArrayList is practically an array anyway, but you can do a lot more with it. It may take you a little longer, but you'll be much further along the road when you're done.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Ben Ooms
Ranch Hand

Joined: May 16, 2011
Posts: 44

Also check your student(s) class. Like designed right now if you create two students they will share the properties because you marked them as static. This means that if you do this:


Both Student a and b will have the FullName == "student b "
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39076
    
  23
Ben Ooms is right. I think you need to go back to get your Student class working correctly, without any static members. Only then consider arrays or Lists or whatever.
 
GeeCON Prague 2014
 
subject: storing user input in an array