为啥写成(1+“” "小明")
给后来者:等你学到下一节,就会明白老师的用意.
下一节中要实现向Student类型的List中添加1000以内随机的id,这时怎么写?
总不能syso("random.nextInt()","小明");吧
相比之下,syso(random.nextInt() +"","小明");直接将int类型的id转换为String类型的,方便很多(相比于新建变量)
给后来者:等你学到下一节,就会明白老师的用意.
下一节中要实现向Student类型的List中添加1000以内随机的id,这时怎么写?
总不能syso("random.nextInt()","小明");吧
相比之下,syso(random.nextInt() +"","小明");直接将int类型的id转换为String类型的,方便很多(相比于新建变量)
2017-02-09
public class HelloWorld {
public static void main(String[] args) {StringBuilder str =new StringBuilder();str.append("jaewkjldfxmopzdm");int count=1;for(int i=str.length()-1;i>=0;i--){
if(count%3==0) {
str.insert(i,','); }
count++;
System.out.print(str.toString());
}
}
public static void main(String[] args) {StringBuilder str =new StringBuilder();str.append("jaewkjldfxmopzdm");int count=1;for(int i=str.length()-1;i>=0;i--){
if(count%3==0) {
str.insert(i,','); }
count++;
System.out.print(str.toString());
}
}
2017-02-09
已采纳回答 / weibo_i萌到自然醒_0404065
String ID = console.next(); 你的位置要放在while里面public void testRemove(){ Scanner console = new Scanner(System.in); while (true){ System.out.println("请输入要删除的学生ID:"); String ID = console.next(); Student st = map.get(ID); if(s...
2017-02-09
最赞回答 / ziom
看需求,需要的时候就使用。比如你要存储多条数据,就可以用list集合。初学者其实不用考虑这种问题,等练习的多了,敲的代码多了,自然会遇到各种场景,也就能明白它的用处。求采纳。
2017-02-09
已采纳回答 / ziom
testEx2()会出异常,但是你把catch注释了,它当然捕获不到,而且因为这是非检查异常,所以系统不会自动抛出,所以定义testEx2() 时后面的throws Exception等于没起到作用,也即上一级的testEx1()和testEx()都不会捕获到异常
2017-02-08