作者在 2011-12-21 08:27:17 发布以下内容
public class StringExample{
public static void main(String[] agrs){
String s1 = new String("you are a student"),
s2 = new String("how are you");
if(s1.equals(s2)){
System.out.println("s1与s2相同");
}else{
System.out.println("s1与s2不同");
}
String s3=new String("22030219851022024");
if(s3.substring(0,6).equals("220302")){
System.out.println("吉林身份证");
}
String s4 = new String("你"),
s5 = new String("我");
if(s4.compareTo(s5)==0){
System.out.println("按字典序s4大于s5");
}else{
System.out.println("按字典序s4小于s5");
}
//int position = path.indexOf(path.split("\\\\")[path.split("\\\\").length-1]);
int position=0;
String path="d:\\text\\java\\b.java";
position=path.lastIndexOf("\\");
System.out.println("d:\\text\\java\\b.java最后出现\\的位置是"+position);
String fileName=path.substring(position+1);
/*
String tempp=path.substring(0,position);
int pos=tempp.lastIndexOf("\\");
tempp=tempp.substring(pos+1,position);
System.out.println(tempp);
*/
System.out.println("d:\\text\\java\\b.java 中的文件名是"+fileName);
String s6 = new String("100"),
s7 = new String("123.678");
int n1=Integer.valueOf(s6);
double n2=Double.valueOf(s7);
double m=n1+n2;
System.out.println(m);
String s8=String.valueOf(m);
position = s8.indexOf(".");
String temp = s8.substring(position+1);
System.out.println("数字"+m+"有"+temp.length()+"位小数");
String s9 = new String("AbCDEF");
char a[] = s8.toCharArray();
for (int i = a.length-1; i>=0; i--){
System.out.print(" "+a[i]);
}
// System.out.println(s8);
}
}