Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • About Us
  • Toggle search form

Frequently Asked Java Program 02: Java Program to Check if Any String is Palindrome Without Using Reverse Method

Posted on 02/19/2025 By admin

Hello Folks,

As part of Frequently Asked Java Programs In Interviews For Freshers And Experienced,  in this post we will see a Java program to verify if a given string is palindrome without using inbuilt reverse method.

WHAT IS A PALINDROME STRING?

A palindromic string is a string that remains the same when its characters are reversed.

For Example: NAAN, AMMA AMMA etc.

Logic:

Since we can not use built in reverse method, so we will use different logic.

  1. We will convert given string in to char array first.
  2. Read char from char array from last index and concatenate.

Java Program:

package StringPrograms;

import java.util.Scanner;

public class PalindromeCharString {
        public static void main(String[] args) {

                // Reading string from user input
                Scanner sc = new Scanner(System.in);
                System.out.println("Please enter the string to check palindrome:");
                String inputByUser = sc.nextLine();
                
                // Closing input scanner 
                sc.close();
                
                // converting string in to char array
                char[] stringInChar = inputByUser.toCharArray();
                
        // Declaring an empty string variable to store reverse string
        String reverseInput = "";
                
        // reading char by char from end of array till first and forming a string
                for (int i = stringInChar.length - 1; i
Uncategorized

Post navigation

Previous Post: Log4j2 tutorials
Next Post: Page Factory In Selenium Webdriver: Inbuilt Page Object Model Of Selenium

Related Posts

TestNG Tutorials 17: Can @Test Annotation Be Used For A Class In TestNG? | Make Selenium Easy Uncategorized
Interview Experience at Harman Connected Services Bangalore for Manual & Automation Testing Profile – Aug-2019 Uncategorized
Make Selenium Easy – Page 17 Uncategorized
JsonPath Expressions Uncategorized
Generate random numbers using Javafaker API – Java Uncategorized
TestNGMain – Make Selenium Easy Uncategorized

Recent Posts

  • How to Set Up Selenium WebDriver with Python Step by Step
  • How to Set Up Selenium WebDriver with Java from Scratch
  • What Is Selenium and Why It Is the Most Popular Test Automation Framework
  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark