File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
EJB 3 in Action
this week in the
EJB and other Java EE Technologies
Programmer Certification (SCJP/OCPJP)
Joined: Jun 24, 2005
Oct 05, 2005 00:03:00
byte i = 123; //(integer)
int i = 123L; //(long)
Joined: Mar 13, 2005
Oct 05, 2005 00:27:00
byte holds upto 127 so 123 is small enough for a byte
Raghu<br />SCJP 1.4<br />SCWCD 1.4<br />SCBCD 1.3
Joined: Jun 22, 2005
Oct 05, 2005 00:46:00
Whether it be 123 or 143
All integral numbers are "int" by default.
Similary remember this all floating points be it 12.3 or 89.7382 they are "double" by default.
Integers can be assigned to byte, short or character provided they are in their acceptable range. Your case, 123 fits in byte so ok.
Next is trying to fit a "long" into an "int" which is not possible. Hope this helps...
Keep Smiling Always — My life is smoother when running silent. -paul
The Linux Documentation Project
I agree. Here's the link:
subject: Literals assignements
SCJP Brainteaser (12)
Get in if you like generics
who can tell me why?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014