Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
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:
Beginning Java
data type short
ramchander yshetti
Ranch Hand
Posts: 97
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hai,
would your please clear my problem
i.e
when i am using
short a=10;
short b=20;
short c=a+b;
System.out.println(c);
->it is giving compilation error that loss of precission..
please clear this.
Chetan Raju
Ranch Hand
Posts: 109
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
short a=10; short b=20; short c=a+b; System.out.println(c);
By default,
java
converts all shorts/bytes to an int in an expression for evaluation. In the 3rd line, both a and b are converted implicitly into integers and then evaluated as an int. And assigning an int to a short requires type cast.
Burkhard Hassel
Ranch Hand
Posts: 1274
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi, cowboys,
for a longer answer, see
this thread
.
It's about the same problem, just with byte instead of short.
Yours,
Bu.
all events occur in real time
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Why this raises ab error?
Error Come in this Code
Boxing and Autoboxing
Error in the Following Code.
For loop clarification
More...