| Author |
Autoboxing, checking is two objects refer to the same object
|
Jean Osorio
Greenhorn
Joined: Aug 11, 2010
Posts: 9
|
|
Hi everybody, I have the following code
public class AutoBoxingObj {
Integer y = new Integer(567);
Integer x = y;
System.out.println(y==x);
}
but when I try System.out.println(y==x); I get the following compiler error:
cannot find symbol
symbol: class out
location: class java.lang.System
<identifier> expected
cannot find symbol
symbol: class y
location: class AutoBoxingObj
<identifier> expected
And I don't undertand what's going on ...please some help.
|
 |
Hunter McMillen
Ranch Hand
Joined: Mar 13, 2009
Posts: 490
|
|
You need to place your code inside of a method(most likely the main method) in order for it to function the way you want it to.
Hunter
|
"If the facts don't fit the theory, get new facts" --Albert Einstein
|
 |
Jean Osorio
Greenhorn
Joined: Aug 11, 2010
Posts: 9
|
|
|
Thanks!!!
|
 |
 |
|
|
subject: Autoboxing, checking is two objects refer to the same object
|
|
|