SarahDoesIt
2012-11-11 13:11:36 UTC
This is my error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The type Queue is not generic; it cannot be parameterized with arguments
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
// Create queue
Queue
// 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);
}
}