Two Laptop Bag*
The moose likes Beginning Java and the fly likes Autoboxing, checking is two objects refer to the same object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Autoboxing, checking is two objects refer to the same object" Watch "Autoboxing, checking is two objects refer to the same object" New topic
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: 492

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!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Autoboxing, checking is two objects refer to the same object
 
Similar Threads
operator && cannot be applied to boolean,int - error
ArrayList?
Using the drawoval method
Polymorphic Arguments
Problem on Generic example from K&B study guide