A string of keyboard input

java.util.Scanner Import; 
// string keyboard input
public class ZiFuChuan {
// define a main method
public static void main (String [] args) {
create output objects precautionary statements and //
Scanner sc = new Scanner (System .in);
System.out.println ( "Please enter an arbitrary word");
// receiving data, the needed entry type string string
string X = sc.nextLine ();
Comparative need // string equals without symbol ==
if (x.equals ( "any word")) {
System.out.println ( "output statement");
}
}
}

Guess you like

Origin www.cnblogs.com/shlo/p/11666167.html