File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Byte Wrapper class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Byte Wrapper class" Watch "Byte Wrapper class" New topic
Author

Byte Wrapper class

Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
Hi all,

I am trying to do this,

but it's giving me a compilation error as constructor Byte(int) is not defined. Why is it taking 10 as an int? But when I do this, it's working!!


Can someone tell me why?/

Thanks.


Be Humble... Be Nice.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10909
    
  12

because literals are taken as ints by default. The compiler is smart enough to figure out that

byte b=10;

is ok. However, there is no constructor for a Byte that takes an int, so it fails.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
I did not know literals are take int by default. Thanks for the reply Fred.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Byte Wrapper class
 
Similar Threads
var args method
wrapper classes
image is not beeing drawn
Easy Queries
What's wrong with the program?