CodePudding user response:
Because you have 2 next if the judgment of the conditions (), suggest to have a look at the first Scanner class API and come back to your code,CodePudding user response:
Using a flow, can reuse, it is not necessary to enter a create a stream objectCodePudding user response:
And you should receive variable with the input data rather than in the if input twice againCodePudding user response:
System. Out.println ("?" );
System. Out. Println (" Y/N ");
Scanner input=new Scanner (System. In);//advice to have a look at the Scanner API manual
String choose=input. NextLine ();
If (" Y ". The equals (choose toUpperCase ())) {//it is best to use when using the equals constant. Equals, can avoid NullPointerException
System. The out. Println (" name ");
String name=input. NextLine ();
System. The out. Println (" hello, "+ name +" password ");
String=input PSD. NextLine ();//as far as possible don't use next (), if you have 12, 345, the program was over
If (PSD) length ()==6) {
System. The out. Println (" again ");
If (PSD) equals (input nextLine ())) {
System. The out. Println (" success ");
} else {
System. The out. Println (" fail ");
}
}
}
Input. The close ();
CodePudding user response:
A child into the pit again