import java.util.Scanner; /**Alphabetze illustrates the following methods in the String class: * compareTo * startWith * endsWith */ public class Alphabetize { public static void main(String[] args) { String fruit1 = "banana", fruit2="apple"; System.out.println(fruit1 + "\n" + fruit2); System.out.println("in alphabetical order:"); // no good: if (fruit1 < fruit2) ; if (fruit1.compareTo(fruit2) < 0) System.out.println(fruit1 + "\n" + fruit2); else System.out.println(fruit2 + "\n" + fruit1); } } /*********** LAB ******************* * Write a method that counts how many times a particular pattern occurs * in a text. The method accepts: * 2 Strings * and returns an int ****/