• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is wrong with this ?  RSS feed

 
kim yong
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is wrong with the following code, It should give me a compilation error, but why is it not giving me that :


please tell me this ...
 
Mahesh Bhatt
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kim,

This is quite simple,


here in line 1 and line 2, two varibles are declared one is byte and the other is long. The code in line 3, can be simplified as :



Whenever there is a statement like above, the compiler provides an implicit cast.

Hope it helps you.
 
Elouise Kivineva
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two points:
(1) The maximum value of a byte is 127. 1001 is a whole lot more than a byte.
(2) using l (lower-case L) as a variable name is a bad idea because a lower-case L looks exactly like a 1 (one).
[ October 04, 2004: Message edited by: Elouise Kivineva ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!