Help with challenge: Unique Characters in a String

https://www.codecademy.com/code-challenges/code-challenge-unique-characters-in-a-string-java

I get the following error when I test my code and I don’t understand what it means:
Tests failed to run due to an error:

"./LETest.java:27: error: ‘)’ expected if (actual == true or actual == false) { ^ ". Check your code and try again.

Here is my code:

import java.util.*;

public class UniqueCharacters {
  public static void main(String[] args) {
    System.out.println(uniqueCharacters(""));
  }

  public static boolean uniqueCharacters(String strIn) {
    Boolean result = true;
    char[] strInArray = strIn.toCharArray();
    for (int i = 0; i < strInArray.length; i++) {
      for (int j = i + 1; j < strInArray.length; j++) {
        if (strInArray[i] == strInArray[j]) {
          result = false;
          return result;
        }
      }
    }
    return result;
  }
}

The only thing I can think of has to do with this instruction:

Note that if the function is called with an empty string ( "" ), the program should return an error message.

I don’t know if that should be up to you or not. Otherwise, not sure what the problem is. (I don’t see the toCharArray() method as problematic in the sense that it should still function). Is this a bug in the tester?

1 Like

that was a mistake on my part making “result” an object rather than a primitive.

But fixing it doesn’t seem to change anything or address the tester error.

1 Like