
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to check whether one String is a rotation of another.
To find weather a string is rotation of another, concat the first string to itself twice and find weather
Example
public class Sample { public static void main(String args[]){ String str1 = "gala"; String str2 = "alag"; String s3 = str1+str1; if(s3.contains(str2)) { System.out.println("str1 is rotation of str2"); } else { System.out.println("str1 is not rotation of str2"); } } }
- Related Questions & Answers
- Program to check whether one string can be 1-to-1 mapped into another string in Python
- Program to check whether every rotation of a number is prime or not in Python
- Java Program to construct one String from another
- Java Program to Check Whether the Given String is Pangram
- Java program to check whether a given string is Heterogram or not
- Program to check whether a string is subsequence of other in C++
- Check if a given string is a rotation of a palindrome in C++
- Program to check whether one point can be converted to another or not in Python
- Program to check one string can be converted to another by removing one element in Python
- In MySQL, how can we check whether a string of a specified pattern is not present within another string?
- Check if it is possible to transform one string to another in Python
- C# program to check whether a given string is Heterogram or not
- Python program to check whether a given string is Heterogram or not
- Program to check whether one tree is subtree of other or not in Python
- Java Program to Check Whether a Number is Positive or Negative
Advertisements