Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class TryToCompareString
  3. {
  4. public static void main(String[] args)
  5. {
  6. String aName = "test";
  7. String anotherName;
  8. Scanner input = new Scanner(System.in);
  9. System.out.println("Enter your name");
  10. anotherName = input.nextLine();
  11.  
  12.  
  13. if (aName == anotherName)
  14. {
  15. System.out.println(aName + " equals " + anotherName);
  16. }
  17. else
  18. {
  19. System.out.println(aName + " does not equal " + anotherName);
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement