currLet = str.charAt(currPos);AStringvalue can’t be assigned to achar, they are different types, apples and orangesif (currLet = str.charAt(currPos + 1)) {is actually an assignment (makecurrLetequal to the value ofstr.charAt(currPos + 1))if (currLen > maxLen) {–maxLenis undefined- You never
returnanything from the method…
Try changing:
String currLet = "";to something more likechar currLet = '\0';andString maxLet = "";tochar maxLet = '\0';if (currLet = str.charAt(currPos + 1)) {to something likeif (currLet == str.charAt(currPos + 1)) {- Add
int maxLen = 0to your variable declerations (may be underint maxCount = 0)
Now, based on your example code, public int longestRep(String str) { will need to be public static int longestRep(String str) { in order for you to call from you main method…