Ugur Aydın Ugur Aydın - 5 months ago 12
Java Question

I javac my program on console but it didn't work(Linux)

I'm new at Java and I have a question.

I wrote this code.

{string isim = "Ali";boolean özne == true;if ( özne ){ System.out.println("Merhaba" + isim); }}}


When I javac it in console, it says:

Muz.java:5: error: ';' expected
boolean özne == true;
^
1 error


What I need to do to fix this?

Please HELP ME!!!

Answer

Use = instead of == to affect true to your boolean variable, and the correct spelling for the class string is String.

You will also need to declare your class, I don't see it in your code snippet but in your case it should be something like that knowing that the name of your file is Muz.java

public class Muz {
    public static void main(String[] args) {
        String isim = "Ali";
        boolean özne = true;
        if ( özne ){ 
            System.out.println("Merhaba" + isim); 
        }
    }
}