While("abc"); causes an error in java and it does not cause any error in c . Why? -


i tried below code in both java , c++ , throwed error in java while not throw error in c++. why ?

while("abc"){ } 

i know purely depends on property of languages. know why java set condition boolean values should allowed in loops ?

i believe talking compiler error , not run-time

in case of java

while ( expression ) {  // expression must evaluate boolean value true or false // far knwo "abc" neither true or false when comes java hence error } 

in c

while ( expression ) {  // expression can gives value of either 0 or number  // "abc" in case evaluate address positive integer hence no error } 

Comments

Popular posts from this blog

xml - Extract substrings with XSLT -

math - "ELO Rating" and how does "TSR Rating" work? -

How can do a tuple comparison in coffeescript similar to that in python? -