public class RotateString { public static String rotateString(String str, int rotationCount) { if (str == null || str.isEmpty() || rotationCount <= 0) return str; int len = str.length(); rotationCount = rotationCount % len; // To handle cases where rotationCount > length return str.substring(len - rotationCount) + str.substring(0, len - rotationCount); } public static void main(String[] args) { String str = "JavaIsFun"; System.out.println("Rotated String: " + rotateString(str, 3)); } }