| | |
single array objects
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2005
Posts: 73
Reputation:
Solved Threads: 0
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:
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:
•
•
Join Date: May 2005
Posts: 55
Reputation:
Solved Threads: 1
Suppose you want to create an array of <type> with size 1555.
<type> can stand for int, double, or String
The syntax is:
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.
For more help, www.NeedProgrammingHelp.com
<type> can stand for int, double, or String
The syntax is:
Java Syntax (Toggle Plain Text)
<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)
//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(); }
![]() |
Similar Threads
- Dynamic memory for an array of objects (C++)
- Array Problem (C++)
- Help : Pointers to array of class objects . (C++)
- sorting through an array of objects (Java)
Other Threads in the Java Forum
- Previous Thread: Classes
- Next Thread: Making a Chatting Application
| Thread Tools | Search this Thread |
addball addressbook android api applet application apps array arrays automation binary bluetooth businessintelligence button card chat class classes client code collision component crashcourse css database draw eclipse ee error event exception fractal free game gis givemetehcodez graphics gui html ide image input integer integration j2me java javadoc javafx javaprojects jni jpanel julia jvm key linux list loan loop machine map method methods migrate mobile netbeans newbie nls oracle output phone physics print problem program programming project radio recursion scanner screen se server service set size sms socket software sort sql string swing textfield threads time transfer tree trolltech utility windows






