INSTAGRAM : / javac_programming
CODE :
import java.util.Queue;
import java.util.Scanner;
import java.util.LinkedList;
class PalindromeTest {
public static void main(String[] args) {
System.out.print("Enter any string:");
Scanner in=new Scanner(System.in);
String inputString = in.nextLine();
Queue queue = new LinkedList();
for (int i = inputString.length()-1; i _=0; i--) {
queue.add(inputString.charAt(i));
}
String reverseString = "";
while (!queue.isEmpty()) {
reverseString = reverseString+queue.remove();
}
if (inputString.equals(reverseString))
System.out.println("The input String is a palindrome.");
else
System.out.println("The input String is not a palindrome.");
}
}
Output 1:
Enter any string:xyzzyx
xyzzyx
The input String is a palindrome.
Output 2:
Enter any string:xyz
The input String is not a palindrome.
Nesta página do site você pode assistir ao vídeo on-line java program to check palindrome string using Queue duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Aman Tripathi 23 Maio 2021, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 195 vezes e gostou 6 espectadores. Boa visualização!