About 28,600 results
Open links in new tab
  1. java - Using int vs Integer - Stack Overflow

    May 16, 2012 · I came across a class using Integer variables to capture size to be used in a for loop. Is this good practice or should we use the int primitive data type? Integer size = …

  2. What is the difference between Integer and int in Java?

    An Integer (with capital I) holds a reference to an object of (class) type Integer, or to null. Java automatically casts between the two; from Integer to int whenever the Integer object occurs as an …

  3. java - Integer vs int: with regard to memory - Stack Overflow

    Dec 7, 2011 · For example, it might surprise you to know that the size ratio of an int value to an Integer object — the smallest object that can hold an int value — is typically 1:4. Integer is an object which …

  4. java - Which one to use, int or Integer - Stack Overflow

    May 11, 2017 · Integer is a better option, as it can handle null; for int, null would become 0, silently, if resultSet.getInt(..) is used. Otherwise, it might throw some exception, something like, "Unable to set …

  5. java - Integer.class vs int.class - Stack Overflow

    Mar 18, 2014 · What is the difference between Integer.class, Integer.TYPE and int.class? acc to me Integer.class is a reference of Integer (Wrapper) Class object but what is then int.class as int is not a …

  6. Java: Integer equals vs. - Stack Overflow

    As of Java 1.5, you can pretty much interchange Integer with int in many situations. However, I found a potential defect in my code that surprised me a bit. The following code: Integer cdiCt = ....

  7. How to convert int[] into List<Integer> in Java? - Stack Overflow

    Jul 2, 2009 · How do I convert int[] into List<Integer> in Java? Of course, I'm interested in any other answer than doing it in a loop, item by item. But if there's no other answer, I'll pick that one as the …

  8. java - Cast Double to Integer - Stack Overflow

    You cannot directly cast an Integer to a Double object. Also Double and Integer are immutable objects, so you cannot modify them in any way. Each numeric class has a primitive alternative (Double vs …

  9. Long vs Integer, long vs int, what to use and when?

    15 An int is a 32-bit integer; a long is a 64-bit integer. Which one to use depends on how large the numbers are that you expect to work with. int and long are primitive types, while Integer and Long …

  10. Differences between new Integer(123), Integer.valueOf(123) and just 123

    Jan 27, 2012 · But in JDK 5+, you should really use valueOf because Integer now caches Integer objects between -128 and 127 and can hand you back the same exact Integer (0) object every time …