Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
Primative Casting
Tobi McFarland
Greenhorn
Posts: 10
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hola-
One of my exam prep books gave the following example:
1: byte i = 2;
2: byte j = 3;
3: i = i * j;
Line 3 doesn't compile w/o a cast to byte. If the value is still within the range of a byte why does this happen?
Thanks-
Tobi<p>Aspiring Java Jedi
Ramnath krishnamurthi
Ranch Hand
Posts: 56
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
when u multiply two bytes or two shorts
java
will automatically cast the result to int.That is why u need to type cast the variable i to byte.
Tobi McFarland
Greenhorn
Posts: 10
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks for the info.
Hopefully, that is in the book somewhere.
Tobi
Tobi<p>Aspiring Java Jedi
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
int converted into 4 bytes
Please Explain
Compile time constant
operator presedence
Multi dimensional array
More...