Comparing Integer objects vs int

前端 未结 5 1634
余生分开走
余生分开走 2020-12-10 17:14

I fixed an endless loop by changing Integer to int in the following:

public class IntTest {
    public static void main(String[] args) {
        Integer x=-1         


        
5条回答
  •  無奈伤痛
    2020-12-10 17:31

    Integer is a class wrapper around the Java primitive type int. They are not the same thing. you should be using int instead of Integer unless you have a valid reason (such as ArrayList list;

提交回复
热议问题