Thursday 15 September 2011

java - Could any one please point out the mistake in the IF statement -


I am very new to Java and can detect the problem with IF statement

 < Code> Class SpaceRivor {Public static zero main () {string is maximum = "This is an exam"; Four [] mfl = most fmos Charaire (); {Char current = mfl [dex] for (int dex = 0; dex & lt; mfl.length; dex ++); If (current! = "") {System.out.print (current); } Else {System.out.print ("."); }} System.out.println (); }}    

Looking at the name and code of the class provided, I agree

Your problem is in queue

  If (current! = "") {  

First of all, this is a place No, this is an empty string. Secondly, you should compare it to a character.

It should be like this:

  if (current! = '') {   

No comments:

Post a Comment