Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TryToCompareString
- {
- public static void main(String[] args)
- {
- String aName = "test";
- String anotherName;
- Scanner input = new Scanner(System.in);
- System.out.println("Enter your name");
- anotherName = input.nextLine();
- if (aName == anotherName)
- {
- System.out.println(aName + " equals " + anotherName);
- }
- else
- {
- System.out.println(aName + " does not equal " + anotherName);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement