Filter by Tags

Palindrome of String or reverse a String.

Votes

1

1 0
This Question is asked to:

Write a program of 'Palindrome of String' or 'Reverse a String'.

Manish Rawat
Posted on : Wed, Jan 24, 2018
Views : 63
Comments

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Answers (1)


0
import java.util.Scanner;

class ChkPalindrome

{

public static void main(String args[])

{

String str, rev = "";

Scanner sc = new Scanner(System.in);

System.out.println("Enter a string:");

str = sc.nextLine();

int length = str.length();

for ( int i = length - 1; i >= 0; i-- )

rev = rev + str.charAt(i);

if (str.equals(rev))

System.out.println(str+" is a palindrome");

else

System.out.println(str+" is not a palindrome");

} }



Jaspreet kaur
Thu, Jan 25, 2018
Loading...
Comments

Edit Answer

Submit
This answer will permanently deleted. Do you really want to delete this Answer ?
To Add your Answer Please
LogIn | SignUp

Quick Links

E-Magazines

@

Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..

Ok

Login to Open ESchool OR Create your account    Login   SignUp