// Helene Martin, CSE 142 // Demonstrates the use of String comparison methods import java.util.*; public class StringComparison { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("What is your name? "); String name = console.next(); System.out.print("Age? "); int age = console.nextInt(); // if (name == "Lance") <== bad! //== doesn't work as expected with objects // string comparison methods can be combined with other tests if (name.equals("Lance") && age > 40) { System.out.println("Pain is temporary."); System.out.println("Quitting lasts forever."); } } }