944,052 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 4628
  • Java RSS
Apr 6th, 2005
0

single array objects

Expand Post »
Does neone know the code instruction to store an array of CD objects. Each entry in the array has to be a single object describing a CD.

i.e: Artist Name , Album Name, Number of tracks

i've written the program out but i cannot seem to get the above right.
if you want to have a look at the full program its in my previous thread....


pleez pleez someone help me out i've been frustrated with this problem for two weeks now just cant seem to get it:
Similar Threads
Reputation Points: 13
Solved Threads: 0
Junior Poster in Training
nabil1983 is offline Offline
73 posts
since Mar 2005
Apr 6th, 2005
0

Re: single array objects

Everything you need has been explained to you several times already. I don't see how regurgitating the same knowledge again will make any difference.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Aug 10th, 2005
0

Re: single array objects

Suppose you want to create an array of <type> with size 1555.
<type> can stand for int, double, or String

The syntax is:
Java Syntax (Toggle Plain Text)
  1. <type>[] nameOfTheArray = new <type>[1555];

This creates the 1555 empty slots. The actual contents depends on the type.

For example: an int array always starts with all 0's, a boolean array always starts with all false, a String arrray starts with all null. More generally, any Object array starts with all null.

Java Syntax (Toggle Plain Text)
  1. //To make a CD object array of size 1555 write:
  2. CD[] nameOfTheArray = new CD[1555];
  3.  
  4. //Then you must fill this array with some objects (right now its all null).
  5. for(int i =0; i < nameOfTheArray.length; i++)
  6. {
  7. //put a new CD object at position i
  8. nameOfTheArray[i] = new CD();
  9. }
For more help, www.NeedProgrammingHelp.com
NPH
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
NPH is offline Offline
55 posts
since May 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Classes
Next Thread in Java Forum Timeline: Making a Chatting Application





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC