传值和传引用的区别
public class ChaString {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/*System.out.println(args.length);
if(args.length>0)
{
for(String item:args)
{
System.out.println(args);
}
}
System.out.println();
*/
/*String a="test";
String b= "3";
String c = a+b;
String d = "test"+"3";
System.out.println(c==d);
System.out.println(c.equals(d));
System.out.println(2+1+a);//当字符串在后会先进行整型变量的运算
System.out.println(a+2+1);//当字符串在前 遇见整型变量的时候胡自动转化为字符串
System.out.println(a.concat("3"));
*/
/*String a = "test";
String b = "test";
String c =new String("test");
String d = "te"+"st";
String e = "te";
String f = "st";
String g = e + f;
System.out.println(a==b);
System.out.println(a.equals(b));
System.out.println(c==a);
System.out.println(a.equals(c));
System.out.println(d==a);
System.out.println(a.equals(b));
System.out.println(g==a);
System.out.println(a.equals(g));
*/
/* //String.format格式
String str = String.format("Hello %d,%s", 10111,"wo");
System.out.println(str);
*/
/*
StringBuilder sbStr = new StringBuilder();
sbStr.append("Hello");
//sbStr.insert(2, "d");
//sbStr.delete(2, 3);
sbStr = sbStr.reverse();
System.out.println(sbStr.toString());
*/
//传值和传引用的区别
StringBuffer buffer = new StringBuffer("add");
String s="Hello";
append(s);
System.out.println(s);
append(buffer);
System.out.println(buffer);
//append(strings);
}
private static void append(String s) {
// TODO Auto-generated method stub
s += 1;
}
public static void append(StringBuffer s){
s.append(1);
}
}