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