-1

After doing

String delims = "[\n]";
String[] tokens = text.split(delims); //text is composed of one single word per line

I would need to know how many lines (via the number of components of the corresponding splitted string)

int k=tokens.length(); //does not work

Is there a method for doing this?

Carlos
  • 109
  • 5

1 Answers1

-1

Use the length field:

  int k=tokens.length;

Because tokens is an array you need to use length field, but length() method it's for strings.

Abdelhak
  • 8,299
  • 4
  • 22
  • 36