---
title: "使用StringBuffer变相实现参数的引用传递。"
author: "linshenqi"
date: "2010-04-15T10:17:40Z"
tags: []
categories: ["编程语言"]
slug: "stringbuffer"
draft: false
lastmod: "2010-04-15T10:17:40Z"
id: 644337
url: "https://linshenqi.iteye.com/blog/644337"
---

在网上搜了很多资料，多说java没有引用传递，只有值传递。后来发现可以使用StringBuffer变相实现。


```java

void strAppend(StringBuffer str){
  str.Append("world");
}

public static void main(String args[]){
  StringBuffer str = new StringBuffer("hello");
  strAppend(str);
  System.out.println("str=" + str);
}

```


结果：str=helloworld

  其实java的io(nio)还是很强大的,用的好可以大大提高程序运行效率，看来以后有要好好研究下。