Java Program to Check Palindrome Without Using String Functions

Java Program to Check Palindrome Without Using String Functions. Learn how to write a program to print palindrome or not in java using letters. In the Java programming language, you can make a palindrome or not. The topic of this program is whether or not the word is a palindrome. Madam, Malayalam. mam is a title, phrase, or sequence that reads the same backward as forwards.

Palindrome Program in Java

In Java, a palindrome number is a number that is the same after being reversed. Palindrome numbers include 545, 343, 171, and 48984. It might also be a string such as LOL, MADAM, and so on. 

The next number in the Fibonacci sequence is the sum of the preceding two numbers, for example, 0, 1, 2, 3, 5, 8, 13, 21, 34, 55, and so on. 0 and 1 are the first two numbers in the Fibonacci sequence. 

In Java, there are two approaches to create a Fibonacci series program: Fibonacci Series without Recursion and Fibonacci Series with Recursion. Setting F0 = 0, F1 = 1, and then applying the recursive algorithm yields the Fibonacci numbers. Fn is equal to the sum of Fn-1 and Fn-2.

For Loop in String Java Program

A string is a collection of characters that are separated by quotation marks. All of the methods that a string object can call are listed on this reference page. It will create the output for Palindrome string in java using scanner To concatenate two strings, for example, use the join() function. 

Methods for searching strings. A for loop is a repetition control structure that allows you to construct a loop that must be repeated a certain number of times quickly. This is a Java program that determines whether or not a string is a palindrome. 

Any string can be used as input. To determine whether the entered string is a palindrome or not, we now employ for loops and if-else conditions, as well as the equalsIgnoreCase() method.

Java Program to Check Palindrome Without Using String Functions

import java.util.*;
class Main
{
public static void main(String args[])
{ 
String a, b = "";
Scanner in = new Scanner(System.in); 
System.out.println("Enter the string"); 
a = in.nextLine(); 
int length = a.length(); 
for (int i = length - 1; i >= 0; i--) 
b = b + a.charAt(i);
if(a.equals(b)) 
System.out.println("The string is a palindrome."); 
else
System.out.println("The string is not a palindrome."); 
}
}

Output:

Enter a string

maam

the string is a palindrome