import java.util.*; public class Words { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("Type two words: "); String word1 = console.next(); String word2 = console.next(); System.out.println("word1 and word2 are alliterative? " + alliterative(word1, word2)); } // return whether the two Strings word1 and word2 are alliterative, // that is, whether they start with the same letter, case insensitive public static boolean alliterative(String word1, String word2) { return word2.substring(0, 1).equalsIgnoreCase(word1.substring(0, 1)); /* This code is function, but doesn't follow the tenets of boolean zen: It doesn't use the boolean value appropriately -- it uses the boolean value returned from .startsWith to control a conditional. It's better to simply return the value. if (word2.startsWith(word1.charAt(0)) { return true; } else { return false; } */ } }