wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt on Operators and Assignments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt on Operators and Assignments" Watch "Doubt on Operators and Assignments" New topic
Author

Doubt on Operators and Assignments

Sneha Neil
Greenhorn

Joined: May 31, 2004
Posts: 5
This question is from Dan Chislom's site:
http://www.danchisholm.net/dec20/guide/chapter3/exam1.html

class GFC100 {
public static void main(String[] args) {
final short s1 = 1; // 1
final char c1 = 1; // 2
byte b1 = s1; // 3
byte b2 = c1; // 4
byte b3 = 1; // 5
byte b4 = 1L; // 6
byte b5 = 1.0; // 7
byte b6 = 1.0d; // 8
}}

I can understand the loss of precision errors for b4,b5 and b6.What I don't understand is why there are no such errors for b1 and b2? But, I get such an error when the final keyword is removed form s1 and c1. Can somebody please help me on this?

Thanks!
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
You may find that Dan Chisholm's reponse in this recent post helps.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Sneha Neil
Greenhorn

Joined: May 31, 2004
Posts: 5
Thanx a lot
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt on Operators and Assignments