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

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -