int i=0;
while(str.length()-3-4*i>0)
{
str.insert(str.length()-3-4*i,',');
i++;
}
while(str.length()-3-4*i>0)
{
str.insert(str.length()-3-4*i,',');
i++;
}
2015-07-13
我的源代码:https://www.evernote.com/shard/s512/sh/be1e14d2-551c-4c8e-aaa7-a3d0a384b665/92385c9b287b98c08b2f0a1e2fab2be2
2015-07-13
已采纳回答 / langren1992
这是因为,从Course的构造方法中可以看出,这里比较的两个name都是字符串常量,它们在内存中都保存在了常量池中,而如果两个字符串常量相同,它们在常量池中只有一份的拷贝,所以用==比较地址的时候,它们也是相等的。如果想要使结果为false,可以将Course的构造方法中,this.name = name,修改为this.name = new String(name).这是因为通过new String()创建的字符串被当做对象放在了堆内存中,在堆内存中就算是两个相同的字符串也是有两个拷贝,因此就会返回fa...
2015-07-13
最赞回答 / qq_Faraward_0
问题原因已经找到,初始化students时,用了pupublic void testMap(){ this.students=new HashMap<String,student>(); }构造方法使用了void,相当于并未对students进行初始化,所以指针指向为空,谢谢各位的关注
2015-07-12