English 中文(简体)
为什么把汽车箱标记为警告?
原标题:Why auto-boxing marked as a warning?

我的理解是,应当谨慎地进行汽车拆箱工作,因为未插入的提及可能是无效的。 为什么汽车箱也是警告的标志? 我在这里没有一些陷阱?

最佳回答

如果你不期望业绩问题(在微观刺激方面),你可以安全地消除这一警告。 如果你不了解这里发生汽车箱,这只是一个迹象。 在你有I/O(由于非行交易或出入不便)的工商守则中,汽车箱很难成为履约问题。

问题回答

我将不理会这一“Eclipse”警告,但以下条款我认为不了。 我仍然不完全相信,但我认为,像这些一样,这或许是避免自动化的良好理由。

https://effective-java.com/2010/05/the-advantages-and-traps-of-autoboxing/

自动箱子有助于开发商创建与“转移”收集方法有关的ug,尽管这可能是一种很模糊的 b子。

I ve encountered this bug when I used a random number generator to select the index of an item to remove from an ArrayList. The generator returned a long primitive, which I accidentally tried to use as the parameter for List.remove(int index). The compiler converted the long to a Long and used it in List.remove(Object o), which gave totally different behavior. Luckily, an assert statement caught the error quickly.

According to this discussion of this issue with "remove", someone else ran into a similar problem where their int unexpectedly acted like an Integer, though I don t understand how that happened. Why aren t Java Collections remove methods generic? (see comment by ScArcher2)





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签