single array objects

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2005
Posts: 73
Reputation: nabil1983 is an unknown quantity at this point 
Solved Threads: 0
nabil1983 nabil1983 is offline Offline
Junior Poster in Training

single array objects

 
0
  #1
Apr 6th, 2005
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:
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: single array objects

 
0
  #2
Apr 6th, 2005
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.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 55
Reputation: NPH is an unknown quantity at this point 
Solved Threads: 1
NPH NPH is offline Offline
Junior Poster in Training

Re: single array objects

 
0
  #3
Aug 10th, 2005
Suppose you want to create an array of <type> with size 1555.
<type> can stand for int, double, or String

The syntax is:
  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.

  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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC