package com.test;public class M1001{public static void main(String[] args) {System.out.println("-----------字符串截取----------------");String str = "a,b,c,d,e,,";String[] str1 = null;str1=str.split(",");for(String st : str1){System.out.println(st);}System.out.println("-----------截取文件后缀名  ----------------");String fileNames = "abc.java; hello.text; hello.cpp";String[] lastFileNames = null;lastFileNames = fileNames.split(";");for(String s : lastFileNames){System.out.println(s);int index=s.lastIndexOf(".");//获取“.”坐标String subString = s.substring(index);//截取字符串System.out.println(subString);}System.out.println("----------类型转换-----------------");int n = 123;str=str.valueOf(n);System.out.println(str);System.out.println("-----------字符串中空格问题----------------");String _str1 = "";//为空String _str2 = " ";//非空String _str3 = null;//为空String _str = " ";if(_str !=null && !"".equals(_str)){System.out.println("非空");}else{System.out.println("空");}System.out.println(" AB CD ".length());System.out.println(" AB CD ".trim().length());}
}答案: 
 ———–字符串截取—————- 
 a 
 b 
 c 
 d 
 e 
 ———–截取文件后缀名 —————- 
 abc.java 
 .java 
 hello.text 
 .text 
 hello.cpp 
 .cpp 
 ———-类型转换—————– 
 123 
 ———–字符串中空格问题—————- 
 非空 
 7 
 5
package com.test;import java.io.Console;
import java.util.Arrays;
import java.util.Scanner;public class Main {;public static void main(String[] agrs){char[] cs = new char[]{'A', 'b', 'c'};String str1 = new String(cs);System.out.println("-------------变成哈希值--------------");System.out.println(str1.getBytes());System.out.println("---------------输出ASCII码值------------");System.out.println(Arrays.toString(str1.getBytes()));System.out.println("-------------length--------------");System.out.println("AAA".length());System.out.println("------------索引获取值---------------");System.out.println("AAAc".charAt(3));System.out.println("-----------------返回指定的子字符串出现位置----------");String values1 = "abcdeafbc";String subStr = "fbc";System.out.println(values1.indexOf(subStr));//第一次出现的位置System.out.println(values1.lastIndexOf(subStr));//返回最后一次出现的索引System.out.println("-------------equals--------------");String s1 = new String("abc");String s2 = new String("abc");System.out.println(s1==s2);System.out.println(s1.equals(s2));System.out.println("-------------valueOf--------------");int num = 123;String t = "234";System.out.println(t.valueOf(true));System.out.println(t);System.out.println("-------------大小写转换--------------");System.out.println(s1.toUpperCase());System.out.println(str1.toLowerCase());System.out.println("------------end---------------");}   
}
答案: 
 ————-变成哈希值————– 
 [B@1bbf1ca 
 —————输出ASCII码值———— 
 [65, 98, 99] 
 ————-length————– 
 3 
 ————索引获取值————— 
 c 
 —————–返回指定的子字符串出现位置———- 
 6 
 6 
 ————-equals————– 
 false 
 true 
 ————-valueOf————– 
 true 
 234 
 ————-大小写转换————– 
 ABC 
 abc 
 ————end—————