---
title: "WHY?这样的结果"
author: "java2times"
date: "2008-09-02T04:45:50Z"
tags: []
slug: "why"
draft: false
lastmod: "2008-09-02T04:45:50Z"
id: 235542
url: "https://java2times.iteye.com/blog/235542"
---

public class test{
public static void main(String sgf) {
        StringBuffer a = new StringBuffer("A");
        StringBuffer b = new StringBuffer("B");
        operate(a, b);
        System.out.println(a + "," + b);
    }

    static void operate(StringBuffer x, StringBuffer y) {
        x.append(y);// 在此x经append(y)之后就变成了AB
        y = x;// 为啥y没有改变呢？
    }
}

结果:AB,B