勤奋学习java,有个关于StringTokenizer的问题import java.util.*;
class MyTest
{
public static void main(String[] args)
{
String MyString="I love you. a b c s e f g ";
System.out.println(my1(MyString,7));
System.out.println(my1(MyString,2));
}
public static String my1(String s, int k)
{
StringTokenizer st=new StringTokenizer(s," \t\n\r,.;:");
String f=null;
for(int i=0;i.<
哪个学长教教我
谢谢了先
(more...)
小伙子勤奋啊!
when u use StringTokenizer, in the for loop if u write for( int i =0; i< st.countTokens(); i++) then u may get wrong answer, coz st.countTokens() is variable. In the for loop, u will call st.nextToken(), then after that, st.countTokens() minus 1 already. So u may get null use your program. :st.countTokens() is always count the tokens left.
donot know what is blueJ.
r u lfj??? hehehe
donot know what is blueJ.
r u lfj??? hehehe