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;
  }

Recommended Answers

All 4 Replies

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

post.split(String.valueOf(delimiter));

if you want your delimiter variable to stay a char.

Thank you, it's working now :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.