常用API-String、包装类、System
2013-04-25 23:18
274 查看
[code]import java.io.IOException;import java.util.Arrays;public class fuxi2_string_system_baozhuanglei{public static void main(String[] args){//***********************字符串*************************************************************//String newstr;String str = " Iloveyou";newstr = str.trim();//去掉字符串的前后空格newstr = str.toUpperCase();//将字符串转为大写newstr = str.toLowerCase();//将字符串转为小写newstr = str.substring(1);//从某个位置开始截取字符串生成新的字符串newstr = str.substring(5,8);//从某个位置开始到某个位置截取字符串生成新的字符串newstr = String.valueOf(87899);//将其他类型转为字符串newstr = str.concat("fff");//在原有字符串的结尾加上指定字符串生成新的字符串System.out.println(newstr);boolean bs = str.startsWith("i");//判断是否以某个字符串开头bs = str.endsWith(".doc"); //判断是否以某个字符串结尾bs = str.contains("h");//判断是否包含某个字符串bs = str.isEmpty();//判断字符串是否为空char c = str.charAt(6);//获取字符串某个位置的字符int p = str.indexOf("co");//获取某个字符(串)在字符串中第一次出现的位置,没有返回-1p = str.lastIndexOf('o');//获取某个字符(串)在字符串中最后一次出现的位置p = str.indexOf('v', 3);//从3开始是否包含v,是返回v的位置4,否返回-1p = str.length();//计算字符串长度System.out.println(p);String[] array = str.split("o");//将字符串某个字符分段截取,返回字符串数组System.out.println(Arrays.toString(array));//打印结果 :[ Il, vey, u]//***********************包装类 自动填装箱*************************************************************//boolean f = false;Boolean ff = new Boolean(f);//创建包装类boolean fz = Boolean.parseBoolean("TRue");//将字符串转成基本类型fz = ff.booleanValue();//从包装类转成基本类型char ch = '5';Character cha = new Character(ch);boolean bc = cha.isDigit(ch);//判断字符是否是数字bc = Character.isUpperCase('D');// 判断是否为大写char cz = cha.charValue();//从包装类转成基本类型int in = Integer.MAX_VALUE;//获取整型最大值 2^31 - 1in = Integer.parseInt("568512");//将字符串转成基本类型//***********************System常用API*************************************************************//for (int i = 0; i < 10; i++){System.out.println(i);}System.exit(1);// 退出程序,终止java虚拟机。参数为非0整型。Runtime run = Runtime.getRuntime();//创建runtime对象,通过方法得到try{run.exec("C:/Program Files (x86)/Tencent/QQ/Bin/QQ.exe");// execute 执行exe程序}catch (IOException e){e.printStackTrace();}//////////////////////////////////////////////////////////////////////System.arraycopy(); //高效率复制数组Runtime.getRuntime().exec("D:\\Program Files\\SDK Setup.exe");//启动某个应用}}[/code]
相关文章推荐
- Java常用工具类API(Arrays类,Collections类,包装类,日期类,Math类,Systeml类)
- 【Date、DateFormat、Calendar、Math、System、包装类、正则表达式】常用API
- 黑马程序员--常用API(String、基本数据类型的包装类、System、Runtime、Date、Calendar、Math)
- JAVA基础--IDE&Object类、常用API-String类、常用API-Arrays、System、StringBuffer&Integer类和Date类、对象数组
- JavaEE常用API【Date、DateFormat、Calendar、Math、System、包装类、正则表达式】总结
- 17_常用API_第3天(包装类、System、Math、Arrays、冒泡排序、选择排序、二分查找)
- 常用API(一)——String、StringBuffer与基本类型包装类
- Java常用API(二)String
- 其它常用API__【System】【Runntime】【Date】【Math】等
- String常用方法-API
- JavaSE----API之常用类(Object、Scanner、String)
- 黑马程序员——java常用基本类库String、包装类、异常总结
- 黑马程序员_常用API之BufferString、StringBuilder
- JSTL中c:forEach循环里的值的substr操作及对String操作的常用API
- String常用方法(处理api)
- java.lang.string常用API
- 应用程序开发——常用类(包装类、String、StringBuffer、StringBuilder、日期类)
- 常用对象API(基本数据类型对象包装类的概述和字符串转换成基本数值)
- JSTL中c:forEach循环里的值的substr操作及对String操作的常用API
- java-String及其常用API