Can anyone see what's wrong with this piece of code? When I try to compile I get an error on the first line (line 3) "cannot find symbol, symbol : method split(char)" I have the delimiter btw as a public static final char in the same class.

private static boolean insertPost(String post) {
    String[] tab = post.split(delimiter);
    Pasient currentPasient = findPasient(Integer.valueOf(tab[0]));
    int dayNumber = Integer.valueOf(tab[1]);
    Personel personel = new Personel(tab[2], tab[3]);
    currentPasient.setThreatment(daynumber, personel);
    return true;

Edited by java.util: n/a

5 Years
Discussion Span
Last Post by java.util

the split method only exists for

String[] split(String regex)
Splits this string around matches of the given regular expression.
String[] split(String regex, int limit)
Splits this string around matches of the given regular expression.

or, as your error message stated: "cannot find symbol, symbol : method split(char)"
here's a link to the api's: String api


Hmm, what does that mean, I can't use a char as delimiter, only Strings?


since there is no split method (in the String class) that takes a char as a parameter, that's exactly what it means.
just use


if you want your delimiter variable to stay a char.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.