eclipse写完java怎么获取一个对象后后前面加上赋值
3个回答
2017-06-09 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
public class TestYinYong {
public static void main(String[] args) {
StringBuffer a = new StringBuffer("A");
StringBuffer b = new StringBuffer("B");
//输出a,b的初值 :A,B
System.out.println(a + ","+b);
operate(a,b);
//输出a,b经过一定操作后(operator()方法)的值:AB,B
System.out.println("方法执行后输出:" + a + ","+b);
b=a;
//输出将a赋给b后的值:AB,AB
System.out.println("声明引用处赋值输出:" + a + ","+b);
}
private static void operate(StringBuffer a, StringBuffer b) {
a.append(b);
b=a;
//AB ,AB
System.out.println("方法执行过程赋值输出:" + a + ","+b);
}
}
public static void main(String[] args) {
StringBuffer a = new StringBuffer("A");
StringBuffer b = new StringBuffer("B");
//输出a,b的初值 :A,B
System.out.println(a + ","+b);
operate(a,b);
//输出a,b经过一定操作后(operator()方法)的值:AB,B
System.out.println("方法执行后输出:" + a + ","+b);
b=a;
//输出将a赋给b后的值:AB,AB
System.out.println("声明引用处赋值输出:" + a + ","+b);
}
private static void operate(StringBuffer a, StringBuffer b) {
a.append(b);
b=a;
//AB ,AB
System.out.println("方法执行过程赋值输出:" + a + ","+b);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询