// This program reads in strings and compares them.
// Barry Cornelius, 3 June 2000
import java.io. BufferedReader;
import java.io. InputStreamReader;
import java.io. IOException;
public class StringCompare
{
   public static void main(final String[] pArgs) throws IOException
   {
      final BufferedReader tKeyboard =
                    new BufferedReader(new InputStreamReader(System.in));
      System.out.print("Type in a string: ");
      System.out.flush();
      final String tFirstString = tKeyboard.readLine();
      System.out.print("Now type in another string: ");
      System.out.flush();
      final String tSecondString = tKeyboard.readLine();

      if (tFirstString==tSecondString)
      {
         System.out.println("The same string objects are being used");
      }
      else 
      {
         System.out.println("Different string objects are being used");
      }

      if (tFirstString.equals(tSecondString))
      {
         System.out.println("The two strings have the same characters");
      }
      else 
      {
         System.out.println("The two strings have different characters");
      }

      if (tFirstString.equalsIgnoreCase(tSecondString))
      {
         System.out.println("Ignoring case, they are the same string");
      }
      else 
      {
         System.out.println("Even ignoring case, they are different");
      } //BJCHEREFIRST

      if (tFirstString.startsWith("I love"))
      {
         final String tObjectOfAffection = tFirstString.substring(6);
         System.out.println("You love" + tObjectOfAffection);
      }

      if (tFirstString.endsWith(tSecondString))
      {
         System.out.println("The 1st string ends with the 2nd string");
      }
   }
}
