Home > Back-end >  Appeared in the process of compiling errors if but no else, someone to help me see what is wrong wit
Appeared in the process of compiling errors if but no else, someone to help me see what is wrong wit

Time:12-09

import java.util.Scanner;
Import the Java. Lang. Object;
Public class Test
{

Public static void main (String [] args)
{
String Username="Ivan";
String Password="k56=";
System. The out. Println (" please enter the username and password: ");
Scanner input=new Scanner(System.in);
The String with Username1 is=input. NextLine ();
String Password1=input. NextLine ();
If (with Username1 is equals (Username) & amp; & Password1. Equals (Password));
{
System. Out.println (" login successfully!" );
} else {
System. Out.println (" the user name or password you entered is not correct!" );
}
}
}

CodePudding user response:

Error: 'if', but there is no 'else'} else {this is the error message

CodePudding user response:

The
refer to the original poster qq_45994608 response:
import Java. Util. Scanner;
Import the Java. Lang. Object;
Public class Test
{

Public static void main (String [] args)
{
String Username="Ivan";
String Password="k56=";
System. The out. Println (" please enter the username and password: ");
Scanner input=new Scanner(System.in);
The String with Username1 is=input. NextLine ();
String Password1=input. NextLine ();
If (with Username1 is equals (Username) & amp; & Password1. Equals (Password));
{
System. Out.println (" login successfully!" );
} else {
System. Out.println (" the user name or password you entered is not correct!" );
}
}
}


If you have one more behind the semicolon, to remove

CodePudding user response:

If much behind a semicolon
  • Related