以下java代码片段的输出是什么? [英] What will be the output of following java code snippet?

查看:217
本文介绍了以下java代码片段的输出是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public class Test {

public static void main(String [] args){

HashSet s = new HashSet();

for(short i = 0; i< 100; i ++){

s.add(i);

s.remove(i-1);

}

System.out.println(s.size());

}

}


<剧透删除>

public class Test {
public static void main(String[] args) {
HashSet s = new HashSet();
for(short i = 0; i<100;i++){
s.add(i);
s.remove(i-1);
}
System.out.println(s.size());
}
}

< spoiler removed >

推荐答案

如果你真的找不到答案的话,那就简单地做一个可编辑的b / b
和runnable一段代码,运行它,看看你自己。


亲切的问候,


Jos


ps。回答:1
If you really can''t find the answer by thinking about it simpy cook up a compilable
and runnable piece of code, run it and see for yourself.

kind regards,

Jos

ps. answer: 1



如果你真的找不到答案,可以通过思考来简单地做一个可编辑的回答

和可运行的代码段,运行它并亲自查看。


亲切的问候,


Jos


ps。回答:1
If you really can''t find the answer by thinking about it simpy cook up a compilable
and runnable piece of code, run it and see for yourself.

kind regards,

Jos

ps. answer: 1



是否可以将整数添加到hashset

Whether it is possible to add the integer to hashset



是否可以将整数添加到hashset
Whether it is possible to add the integer to hashset



由于Java 1.5它是:autoboxing(但是你需要一个Set< Short>)


亲切的问候,


Jos

Since Java 1.5 it is: autoboxing (but then you need a Set<Short>)

kind regards,

Jos


这篇关于以下java代码片段的输出是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆