//public class Stringdemo //{public static void main (String args[]){ // String ste="hello"; // char st = ste.charAt(0);//取出指定索引的字符 // System.out.println(st); // } //} /* public class Stringdemo {public static void main(String args[]){ String ste="helloworld"; char [ ] deat = ste.toCharArray(); 将字符串变成字符数组 for (int x=0;x<deat.length ; x++){ //System.out.println(deat[x]+","); deat[x] -=32; } System.out.println(new String(deat) ); 将所有字符数组变成String System.out.println(new String(deat,5,4)); 将部分字符数组变成String } }*/ public class Stringdemo {public static void main(String args[]){ String ste="84546464"; if (isAsa(ste)) {System.out.println("是数字"); } else { System.out.println("不是数字"); } } public static boolean isAsa(String temp){ char [ ] ch = temp.toCharArray();//将字符串转换为数组 for (int x=0; x<ch.length; x++) {if (ch[x] < '0' || ch[x] > '9')//因为不是String类型 所有不能使用"" {return false; } } return true; } }
( 字符与字符串 )2016-09-0118:05:00