public class test

[复制链接]
查看11 | 回复1 | 2009-4-10 13:32:00 | 显示全部楼层 |阅读模式
//test类描述的是方法的传递
public class test9
{
public static void main(String[] args)
{
//创建一个对象类型
String s = new String("Hello ");

//打印其值
System.out.println("before : " + s);

//通过方法去改变其值
changeString(s);

//打印方法改变的值和原值
System.out.println("changeString : " + s);
System.out.println("after : " + s);
}
public static void changeString(String str)
{
str = new String("hi");
str = str + "china!";
}
}
后面的三星怎么理解啊?

回复

使用道具 举报

千问 | 2009-4-10 13:32:00 | 显示全部楼层
str = new String("hi"); //重新赋值strstr = str + "china!"; //str为str和china连接成一个字符串...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行