hi there guys i have this exception when sorting the StringTokenizers this is my code...
public static StringTokenizer[] bubbleSort(StringTokenizer[] s){
StringTokenizer temp;
for(int pass=0;pass<s.length-1;pass++){
for(int index=0;index<s.length-1;index++){
if(compare(s[index],s[index+1])){
temp = s[index];
s[index] = s[index+1];
s[index+1] = temp;
}
}
}
return s;
}
public static boolean compare(StringTokenizer date1, StringTokenizer date2){
date1.nextToken();date1.nextToken();
String h = date1.nextToken();
date2.nextToken();date2.nextToken();
String k = date2.nextToken();
if(h.compareTo(k)<0)
return true;
else return false;
}
they are used simultaneously so it affects one another
this is the error:
Exception in thread "main" java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(StringTokenizer.java:332)
What seems to be the problem?