问题描述
因此,我遇到了一个问题,要求我创建一个字典以将数字存储为键,并将值存储为电话号码。我的第一个代码无法及时执行问题,而我的第二个迭代却可以及时执行。为什么会这样呢? 我的第一个代码段:-
while(sn.hasNext()){
String s=sn.nextLine();
System.out.printf((pb.get(s)==null)?"Not found":"%d=%s%n",s,pb.get(s));} //pb is the hashmap obj
我的第二个代码:
while(sn.hasNext()){
String s=sn.nextLine();
if(pb.get(s)==null){
System.out.println("Not found");
else System.out.println(s+"="+pb.get(s));}
如果我删除System.out.printf内部的条件语句,并用if else替换它,它将在一段时间内通过所有测试用例。为什么会这样?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)