aspose file tools
The moose likes Bunkhouse Porch and the fly likes Downcasting  to Byte Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Books » Bunkhouse Porch
Reply locked New topic

Downcasting to Byte

Sridhar Padala

Joined: Aug 03, 2007
Posts: 20
class Magenta {
static byte a = (byte)127, b = (byte)128, c = (byte)255, d = (byte)256;
public static void main(String args[]) {
System.out.print(a + " " + b + " " + c + " " + d);

How to type cast to byte if the value exceeds byte range? Please explain in detail

Thanks in Advance
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 62291

Please take the time to choose the correct forum for your posts. This forum is for questions on books.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
It is sorta covered in the JavaRanch Style Guide.
subject: Downcasting to Byte