Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Autoboxing, checking is two objects refer to the same object

 
Jean Osorio
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jean Osorio
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic