首页 > 代码库 > String功能测试
String功能测试
package foxe;
import java.io.IOException;
import java.util.StringTokenizer;
public class MainClass {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
String str="1 a 67 fist";
StringTokenizer token=new StringTokenizer(str);
System.out.println("str.length="+str.length());
//token.countToken;
for(int i=0;i<str.length()-1;i++){
System.out.println("i======================ii="+i);
String sk = token.nextToken();i=i+sk.length();
System.out.println("String sk"+i+"="+sk);
try{
double dou=Double.parseDouble(sk);
System.out.println("double dou"+i+"="+dou+"; doub*3="+dou*3);
}catch(Exception e){
e.getMessage();
System.out.println("chang error at "+i);
}
//char chars = str.charAt(i);
//str.equals(Double);
int ints3 = str.hashCode();
System.out.println("ints3="+ints3);
int ints4= str.indexOf(i);
System.out.println("ints4="+ints4);
String ints7 = str.valueOf(i);
System.out.println("ints7="+ints7);
System.out.println("ints **********************************end");
}
}
}