I learned Java almost for the first time, and I saw what was in the example.
import util java.Scanner;
public class A3 {
public static void main(String [] args) {
String str = "hello";
String input = null;
Scanner magic = new Scanner (System.in);
System.out.print("please enter the Text:");
input = magic.next();
if (str == input) {
System.out.println("Text is match!");
} else {
System.out.println("Error! Text isn't match!");
}
magic.close();}
}
I tested and ran
This screen appears, and it doesn't work. JRE10 is in use.
What's the problem?
java
delete jdk 10 version and install 8 version
I don't think Eclipse can support 10.
Currently, support for version 9 is in full swing, so install 8 and test it.
I don't know if you've checked it out
import java.util.Scanner;
public class A3 { public static void main(String[] args) { String str = "hello"; String input = null;
Scanner magic = new Scanner(System.in);
System.out.print("please enter the Text:");
input = magic.next();
if (str.equals(input)) {
System.out.println("Text is match!");
} else {
System.out.println("Error! Text isn't match!");
}
magic.close();
}
}
You can do it like this.
© 2024 OneMinuteCode. All rights reserved.