I receive an error when trying to compile my Java code for a palindrome.
This is my error, and I don't understand why I am receiving this error. Can someone please help me? Thank you.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The type Queue is not generic; it cannot be parameterized with arguments <Character>
at palindrome5.main(palindrome5.java:13)
This is my code:
import java.util.*; public class Palindrome2 { public static void main(String [] args) { String input = args[0]; // For ignoring case String inputString = input.toLowerCase(); // Create stack Stack<Character> stack = new Stack<Character>(); // Create queue Queue<Character> queue = new LinkedList<Character>(); // Add input string to stack and queue for ( int i = 0 ; i < inputString.length() ; i++ ) { stack.push(inputString.charAt(i)); queue.add(inputString.charAt(i)); } boolean palindrome = true; while ( !stack.isEmpty() && palindrome == true ) { if ( Character.isLetter(stack.peek()) && Character.isLetter(queue.peek()) ) { // Check for comparison if ( stack.pop().equals( queue.remove() ) == false ) { palindrome = false; } } else { if ( !Character.isLetter(stack.peek())) stack.pop(); if ( !Character.isLetter(queue.peek())) queue.remove(); } } // Output System.out.println("Text: " + input ); System.out.println("Palindrome: " + palindrome); } }