LinkedList<String>t=new LinkedList<String>();
t.add("1");t.add("*");t.add("2");t.add("+"); t.remove("*"); t.remove("2");
为什麽最后 t.size=3;
t.add("1");t.add("*");t.add("2");t.add("+"); t.remove("*"); t.remove("2");
为什麽最后 t.size=3;
LinkedList<String> t = new LinkedList<String>();
t.add("1");
t.add("*");
t.add("2");
t.add("+");
t.remove("*");
t.remove("2");
System.out.println(t.size());
}
}run:
2
成功生成(总时间:1 秒)
public class NewTest {
public static void main(String[] args) {
LinkedList<String> t = new LinkedList<String>();
t.add("1");
t.add("2");
t.add("*");
t.add("+");
//t.remove("2"); 是移除"2"这个元素
t.remove(2); // 是移除位置为2的元素
t.remove("*");//由于"*"被移除所以这一步并没有移除任何东西
System.out.println(t.size());
}
}
你再看看,你的程序吧,查查API。
(//jTextField1.getText()=“1”
t.add("*");
t.add("2");
t.add("+");
//t.remove("*");
if(t.contains("2"))
{ t.remove("2");}
jTextField1.setText(t.get(1));
结果为“2”呀?如何让其显示“+”;麻烦您了!!