aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Byte This ! 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 This !" Watch "Byte This !" New topic
Author

Byte This !

Zac Roberts
Ranch Hand

Joined: Jan 29, 2002
Posts: 82
Can anyone explain why I get a compiler error from the byte values but not from the int values:

Thanks-
Zac


Zac Roberts<br />SCJP2
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
because in the statement
byte b2 = -b;
the b is promoted to an int because of the unary - sign, thus -b will be of type int which is not assignment compatible with a byte...
See 15.15.4 Unary Minus Operator -
[ February 18, 2002: Message edited by: Valentin Crettaz ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Zac Roberts
Ranch Hand

Joined: Jan 29, 2002
Posts: 82
You are correct sir... and by the way... are you going to have some sort of celebration when you hit 2000 posts, kindof like the millenium... maybe you could have some tequila to go along with the JavaRanch cowboy thing...
Zac
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
I'll get myself some tequilaSSSS, don't worry
[ February 18, 2002: Message edited by: Valentin Crettaz ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Byte This !
 
Similar Threads
If compiler can automatically cast int to byte, then why not long to int?
for loop and byte to int coversion.
switch comparison vs == comparison
Method Overloading with default param values
var args method