aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes wrapper object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "wrapper object" Watch "wrapper object" New topic
Author

wrapper object

saran bala
Greenhorn

Joined: Oct 17, 2007
Posts: 8
can you please explain the reason?

public class Test12{
public static void main(String a[]){
byte b = 100;
Byte b1= new Byte(100);
Byte b2 = new Byte(b);
System.out.println(b1 == b2);
System.out.println(b1.equals(b2));
}
}
What is output?

Answer:Complier error
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14435
    
  23

Try compiling it yourself. What error does the compiler give you exactly? Read the error message carefully and try to understand what it means.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Yogesh Baraskar
Ranch Hand

Joined: Oct 07, 2007
Posts: 33
Byte b1= new Byte(100);
literals like 100 are of integer type by default.

To create a Byte object using new you should pass a byte

Try this
Byte b1= new Byte((byte)(100));
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: wrapper object