Hello I'm currently working with my Java program here is my code:
import java.util.Scanner;
public class StringAct{
public static void main(String[]args){
Scanner inp=new Scanner(System.in);
System.out.print("Enter string: ");
String a= inp.nextLine();
if(a=="angel"){
System.out.print("Valid");
}
else{
System.out.print("Not Valid");
}
}
}
this program asks the user to enter a string, the string that the user should enter is equivalent to "angel" to display valid. If the user types other word it should display not valid and that's my problem with this code. Everytime I type angel it still displays not valid please help me with this thing. Thanks.