简体   繁体   English

为什么使用 Integer.MAX_VALUE 时 BitSet 的大小为负(JVM BUG)?

[英]Why is the size of BitSet negative when using Integer.MAX_VALUE (JVM BUG)?

This was a Java-related bug reported on this thread (only visible for those with with 10k+ reputation points) which was deleted afterwards.这是在此线程上报告的与 Java 相关的错误(仅对具有 10k+ 声望点的人可见),后来被删除。

So the following code:所以下面的代码:

BitSet bs = new BitSet(Integer.MAX_VALUE);
System.out.println(bs.size()); //-2147483648

Result on the following:结果如下:

Output: Output:

-2147483648

Why is the size negative?为什么尺寸是负数?

This was a Java-related bug reported on this thread (only visible for those with with 10k+ reputation points) which was deleted afterwards.这是在此线程上报告的与 Java 相关的错误(仅对具有 10k+ 声望点的人可见),后来被删除。

So the following code:所以下面的代码:

BitSet bs = new BitSet(Integer.MAX_VALUE);
System.out.println(bs.size()); //-2147483648

Result on the following:结果如下:

Output: Output:

-2147483648

Why is the size negative?为什么尺寸是负数?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM