![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 149
Rep Power: 3
![]() |
Objects...
Not sure if this question is Java-specific or not, but in the following example code...
class Ball {
...
}
Ball newball=new Ball();
anotherVariable=newball;Does anotherVariable just point to newball? Does it duplicate it? |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Nov 2004
Posts: 84
Rep Power: 4
![]() |
Try this, and you tell me:
![]() public class Test {
public Test() {
}
public static void main(String[] args) {
Test c = new Test();
Test d = c;
System.out.println(c);
System.out.println(d);
}
}
__________________
HijackThis Team-SFDC |
|
|
|
|
|
#3 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
It only points to the original.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#4 |
|
Expert Programmer
|
Just for future reference you should NOT use newwhatever for an object name because it might get confused the reserved word in java 'new'.
![]() |
|
|
|
|
|
#5 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
|
|
|
|
|
|
|
#6 | |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 149
Rep Power: 3
![]() |
Quote:
|
|
|
|
|
|
|
#7 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Ohhhh, okay. I've been thinking about code too much recently
![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|