• 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

Question on Loops

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
while(false);
for(;false ;

these lines will not compile...the compiler gives error message-unreachable code

does that mean that the boolean check expression must not evaluate to false during compile time??am i right?
 
Sandya Bhaskara
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there was an error...

for(; false ; ) ;
 
Sandya Bhaskara
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
one more question...

this code doesn't compile..
int i= Integer.parseInt("12",65535);
parseInt method takes String and radix as parameters..what is the max value that we can give to the radix so that the code compiles?
the error i got was 65535 greater than Character.MAX_RADIX...soshould i not give a value more than 108(which is the value of Character.MAX_VALUE)?
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sandya,

If you have written a program that contains code that can never be reached, then the compiler will let you know that your program has problems. Unreachable statements are covered in Section 14.20 of the JLS.

An exception to the rule is the if statement. The compiler knows that you might want to use the boolean expression of an if statement as a flag that prevents some blocks of code from being compiled or executed.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sandya Bhaskara:
one more question...

this code doesn't compile..
int i= Integer.parseInt("12",65535);
parseInt method takes String and radix as parameters..what is the max value that we can give to the radix so that the code compiles?
the error i got was 65535 greater than Character.MAX_RADIX...soshould i not give a value more than 108(which is the value of Character.MAX_VALUE)?



The value of MAX_RADIX is 36, because there are 10 digit characters and 26 letter characters in the Latin alphabet. For example, hexadecimal uses the characters 0 - 9 and A - F. Base 36 would use 0 - 9 and A - Z.
 
Sandya Bhaskara
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Dan...thanx for the clarification
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic