Results 1 to 2 of 2
- 10-16-2011, 01:32 AM #1Member
- Join Date
- Oct 2011
- Rep Power
How to create an array of objects which has integer field
I am very new to JAVA and was trying to do the first exercise:
Create an array A of GameEntry objects, which has an integer
scores field, and we clone A and store the result in an array B. If we then immediately set A .score equal to 550, what is the score value of the GameEntry object referenced by B?
First I thought I will declare a variable of 'int scorse;'. Then create an array A of GameEntry like, GameEntry a = new GameEntry(); Cloning a into b would be like b = a.clone(); I can get the idea that both A and B will be pointing to same object if I do a=b; But I just can't understand how to implement(start and end) this problem. I don't seem to grasp the idea of putting things together.
Any help would be really appreciated.
- 10-16-2011, 09:58 AM #2
Re: How to create an array of objects which has integer field
This task shows that array is primitive type in Java. and when you make array clone you will do new array. about compare to objects you must override hashCode and equals methods in you object and then to use equals methods.
- By aks_saxena in forum AWT / SwingReplies: 3Last Post: 04-09-2011, 01:00 PM
- By redmaverick in forum New To JavaReplies: 7Last Post: 10-19-2009, 02:14 AM
- By Hannguoi in forum New To JavaReplies: 1Last Post: 03-31-2009, 06:40 AM
- By stamv in forum JDBCReplies: 1Last Post: 01-22-2009, 05:25 PM
- By trill in forum New To JavaReplies: 1Last Post: 08-07-2007, 07:32 AM