Home » Tip Bank » Java
  • Comment on this Article
Language: Java
Expertise: Intermediate
May 8, 2020

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Watch

Determine if String str2 is a Rotation of String str1

Given two strings, str1 and str2, the code below shows a single line of code that returns whether or not str2 is a rotation of str1.

return (str1 + str1).matches("(?i).*" + Pattern.quote(str2) + ".*");
Octavia Anghel
 
Submit a Tip
Browse "Java" Tips
Browse All Tips
codeschool.com
activatejavascript.org