Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Beginner
Mar 27, 2000

Be Careful When You Cast

Java allows you to cast variables, or change them from one variable type to another. However, it's important to make sure that the final variable type can store all the information from the original variable type, as Java will discard any additional information.

For example, if you cast a variable with a value of 20 from short to byte, you won't lose any information. However, if you make the same cast with an initial value of 20,000, you'll get an incorrect result because a byte variable's maximum value is 127.
Manoj K.
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date