Results 1 to 4 of 4
- 02-05-2012, 11:12 PM #1
Member
- Join Date
- Nov 2011
- Location
- birkenhead
- Posts
- 6
- Rep Power
- 0
Help on how to store details from one class into an Array of another class?
Hi, I am pretty new to Java and just wondering how I can store a person's details from one class into an Array of another class. It also has to be an Array, NOT ArrayList as I already know how to do this :P
My code so far:
public class Member
{
private String surname;
private String firstName;
private String membershipCode;
public Member(String firstName, String surname, String membershipCode)
{
this.firstName = firstName;
this.surname = surname;
this.membershipCode = membershipCode;
}
}
// I also have the usual accessor methods, getName etc.
Now this is my Website Class :
public class Website
{
public Website()
{
String members[] = new String [10]; // Fixed size
}
}
I Basically want to create a member object from "Member class" and store it in the "members Array". And then create another member object untill the fixed array size is full.
I think I am trying to over complicate things?
Any help will greatly be appreciated!
Thank you in advance
- 02-06-2012, 10:30 AM #2
Re: Help on how to store details from one class into an Array of another class?
Hi, am also a java beginner. I got a small doubt to ask in your post.
This is what i understood from your sentence, that you want your string members[] to be like:
members[0]=obj1
members[1]=obj2
members[2]=obj3
If the above result is what u want, then why not use:
"Object[] members" instead of "String[] members"
- 02-06-2012, 08:53 PM #3
Re: Help on how to store details from one class into an Array of another class?
Please use one thread per question. The second thread you started with the same question has been closed.
Help with Arrays please
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 02-06-2012, 08:54 PM #4
Re: Help on how to store details from one class into an Array of another class?
Why do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
how can i store 30 int digits without using bigInteger class
By akeni in forum New To JavaReplies: 19Last Post: 11-10-2011, 06:43 AM -
Showing object details of another related class
By misbah6 in forum New To JavaReplies: 7Last Post: 04-05-2010, 03:48 PM -
help me to store data in a class
By neeraj.singh in forum New To JavaReplies: 2Last Post: 08-06-2009, 08:31 AM -
problem in accessing array values of one class in to jframe class
By cenafu in forum AWT / SwingReplies: 8Last Post: 03-21-2009, 09:34 AM -
Class to store Image+Text
By Gudradain in forum New To JavaReplies: 2Last Post: 11-23-2008, 08:32 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks