class StringExample
{
public static void main(String args[])
{
String s1 = new String("you are a strdent"),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.startsWith("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 = 0;
String path = "c:\\java\\jsp\\A.java";
position = path.lastIndexOf("\\");
System.out.println("c:\\java\\jsp\\A.java中最后出现\\的位置:"+position);
String fileName = path.substring(position+1);
System.out.println("c:\\java\\jsp\\A.java中含有的文件名:"+fileName);
String s6 = new String("100"),s7=new String("123.678");
int n1 = Integer.parseInt(s6);
double n2 = Double.parseDouble(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[]= s9.toCharArray();
for(int i=a.length-1;i>=0;i--)
{
System.out.print(" "+a[i]);
}
String str1 = new String("ABCABC"),str2=null,str3=null,str4=null;
str2=str1.replaceAll("A","First");
str3=str1.replaceAll("B","Second");
str4=str1.replaceAll("C","Third");
System.out.println(str1);
System.out.println(str2);
System.out.println(str3);
System.out.println(str4);
System.out.println(Long.toBinaryString(12345));
System.out.println(Long.toOctalString(12345));
System.out.println(Long.toHexString(12345));
}
}
mbcqss
- 粉丝: 10
- 资源: 108
最新资源
- (源码)基于C语言的系统服务框架.zip
- (源码)基于Spring MVC和MyBatis的选课管理系统.zip
- (源码)基于ArcEngine的GIS数据处理系统.zip
- (源码)基于JavaFX和MySQL的医院挂号管理系统.zip
- (源码)基于IdentityServer4和Finbuckle.MultiTenant的多租户身份认证系统.zip
- (源码)基于Spring Boot和Vue3+ElementPlus的后台管理系统.zip
- (源码)基于C++和Qt框架的dearoot配置管理系统.zip
- (源码)基于 .NET 和 EasyHook 的虚拟文件系统.zip
- (源码)基于Python的金融文档智能分析系统.zip
- (源码)基于Java的医药管理系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈