Q9-7:
package day22.t1;
public class TestQ9_7 {
public static void main(String[] args) {
String s =new String("123456");
int i = Integer.valueOf(s);
System.out.println(i);
Integer i1=Integer.valueOf(s);
int i2 = i1;
System.out.println(i2);
}
}
运行效果图:
8.ABC
11 / 12:
package day22.t1;
public class TestQ9_11 {
public static void main(String[] args) {
String web ="zhengcg@zparkhr.com";
System.out.println(web.substring(0, 7));
int i = web.indexOf("@");
int i1=web.indexOf(".");
if(i!=-1 && i1!=-1){
if(i<i1){
System.out.println("邮箱格式正确");
}
}
}
}
效果图:
13.
package day22.t1;
public class TestQ9_13 {
public static void main(String[] args) {
String s =java.util.UUID.randomUUID().toString();
System.out.println(s);
String s1=s.replace('-', ' ');
System.out.println(s1);
}
}
效果图:
package day22.t1;
public class TestQ9_14 {
public static void main(String[] args) {
String s="ABCDEFGhigklmn1234567";
java.util.Random random=new java.util.Random();
StringBuilder sb= new StringBuilder();
for(int i =1; i<=4;i++){
int a =random.nextInt(21);
char ch = s.charAt(a);
sb.append(ch);
}
System.out.println(sb.toString());
}
}
效果图:
15
package day22.t1;
public class TestQ9_15 {
public static void main(String[] args) {
String s ="1239586838923173478943890234092";
String[] s1 =s.split("1");
System.out.println("1出现了"+(s1.length-1)+"次");
String[] s2 =s.split("2");
System.out.println("2出现了"+(s2.length-1)+"次");
String[] s3 =s.split("3");
System.out.println("3出现了"+(s3.length-1)+"次");
String[] s4 =s.split("4");
System.out.println("4出现了"+(s4.length-1)+"次");
String[] s5 =s.split("5");
System.out.println("5出现了"+(s5.length-1)+"次");
String[] s6 =s.split("6");
System.out.println("6出现了"+(s6.length-1)+"次");
String[] s7 =s.split("7");
System.out.println("7出现了"+(s7.length-1)+"次");
String[] s8 =s.split("8");
System.out.println("8出现了"+(s8.length-1)+"次");
String[] s9 =s.split("9");
System.out.println("9出现了"+(s9.length-1)+"次");
}
}