Make Selenium Easy

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

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:

 

Output:
Please enter the string to check palindrome:
NANA
Inout string:NANA
Reverse String:ANAN
Entered string is not palindrome.
===============================================================
Please enter the string to check palindrome:
AMMA
Inout string:AMMA
Reverse String:AMMA
Entered string is palindrome.

You can run above program for multiple inputs and if it fails for any condition, let me know.

#HappyCoding

Author: Amod Mahajan

A software Tester who is paid to judge products developed by others. Currently getting paid in American Dollars. Writing technical posts and creating YouTube videos are my hobbies.

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.

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

by Amod Mahajan time to read: 1 min
0
%d bloggers like this: