aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Byte Wrapper class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Byte Wrapper class" Watch "Byte Wrapper class" New topic
Author

Byte Wrapper class

RAGU KANNAN
Ranch Hand

Joined: Dec 16, 2005
Posts: 103
Hello,

The byte limit is from -128 to +127. The following class tries to create wrapper class of Byte. Why this int value 123 is not doing implicit casting. Pls explain to me.

Thanks, Raghu.K

public class Test{
public static void main (String args[]){
Byte b = new Byte(123);
System.out.println("b "+b);
}
}
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2341
Method invocation conversion does not include narrowing primitive conversions.

123 is an int, and the only constructors in Byte accept a byte or a String, but not an int.
shilpa Reddy
Ranch Hand

Joined: Jul 26, 2006
Posts: 42
can you give an example of for byte declaration.That wuld be helpful
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
Byte b1=new Byte((byte)123);
Byte b2=new Byte("123");
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Byte Wrapper class
 
Similar Threads
Ranch roundup game question
Can we return Byte for a method that has a return type int
Byte b = new Byte(123); //fails to compile ! :mad:
getting confused
Byte Doubt