954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

single array objects

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:

nabil1983
Junior Poster in Training
73 posts since Mar 2005
Reputation Points: 13
Solved Threads: 0
 

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.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

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

The syntax is:

<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.

//To make a CD object array of size 1555 write:
CD[] nameOfTheArray = new CD[1555];

//Then you must fill this array with some objects (right now its all null).
for(int i =0; i < nameOfTheArray.length; i++)
{
	//put a new CD object at position i
	nameOfTheArray[i] = new CD();
}


For more help, www.NeedProgrammingHelp.com

NPH
Junior Poster in Training
55 posts since May 2005
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You