I have read that in this exersise may be bug. I don't know what to do, because everything in this program do it's funkction.
package en.codegym.task.pro.task09.task0915;
import java.util.Arrays;
import java.util.StringTokenizer;
/*
StringTokenizer
*/
public class Solution {
public static void main(String[] args) {
String packagePath = "java.util.stream";
String[] tokens = getTokens(packagePath, "\\.");
System.out.println(Arrays.toString(tokens));
}
public static String[] getTokens(String query, String delimiter) {
StringTokenizer tokenizer = new StringTokenizer(query, delimiter);
int i = 0;
int count = tokenizer.countTokens();
String[] list = new String[count];
while (tokenizer.hasMoreTokens() && count < 7){
String token = tokenizer.nextToken();
list[i] = token;
i++;
}
int newListLength = 0;
for (int j = 0; j < list.length; j++) {
if (list[j] != null)
newListLength ++;
}
String[] newList = new String[newListLength];
for (int j = 0; j < newListLength; j++) {
newList[j] = list[j];
}
return newList;
}
}