Exercise 2A -- finding palindromes

Palindromes are words which are the same when spelt backwards. For example:

abba

pop

 

Write a program Palindrome.java which prints out the palindromes from the file words. Note that in this file, every word is on a line of its own.

Notes:

  1. You'll read in the file a line at a time.
  2. Provide a method
    boolean isPalindrome(String word)
    which returns true or false according to whether word is a palindrome.



© 2001 Mark Ryan and Alan Sexton