StringBuilder类
package Demo01;
public class Demo01StringBuilder {
public static void main(String[] args) {
StringBuilder bu1=new StringBuilder();
System.out.println("bul:"+bu1);
StringBuilder bu2=new StringBuilder("abc");
System.out.println("bu2:"+bu2);
}
}
public class Demo02StringBuilder {
public static void main(String[] args) {
StringBuilder bu = new StringBuilder();
StringBuilder bu2=bu.append("abc");
System.out.println(bu);
System.out.println(bu2);
System.out.println(bu==bu2);
StringBuilder bu3=new StringBuilder();
bu3.append("李长洲");
bu3.append(21);
bu3.append("168");
System.out.println(bu3);
System.out.println("abc".toUpperCase().toLowerCase().toUpperCase().toUpperCase());
bu3.append("abc").append(1).append(true).append(8.8).append("是");
System.out.println(bu3);
}
}
包装类
包装类_装箱与拆箱
package Demo02;
public class Demo01Integer {
public static void main(String[] args) {
Integer in1=new Integer(1);
System.out.println(in1);
Integer in2=new Integer("1");
System.out.println(in2);
Integer in3=Integer.valueOf(1);
System.out.println(in3);
Integer in4=Integer.valueOf("1");
System.out.println(in4);
}
}
package Demo02;
import java.util.ArrayList;
public class Demo02Integer {
public static void main(String[] args) {
Integer in=1;
in = in +2;
System.out.println(in);
ArrayList<Integer> list=new ArrayList<>();
list.add(1);
int a=list.get(0);
for (int i = 0; i <list.size() ; i++) {
System.out.println(list);
}
System.out.println(a);
}
}
[1]
1
基本类型与字符串类型之间
package Demo03;
public class Demo01String {
public static void main(String[] args) {
int i1=100;
String s1=i1+"";
System.out.println(s1+200);
String s2 =Integer.toString(100);
System.out.println(s2+200);
String s3 = String.valueOf(100);
System.out.println(s3+200);
int i = Integer.parseInt(s1);
System.out.println(i-10);
int a=Integer.parseInt("a");
System.out.println(a);
}
}