Can someone explain me using Integer, Boolean, etc. instead of their primitive types in JAVA?
I canβt understand what benefits they provide. They seem to create unnecessary problems with handling null values.
Thank!
Boolean, Integer, Long, ... are objects. You can use them in places where you cannot use primitive types, for example.
Boolean
Integer
Long
Map
null
Number
<strong> Examples:
new ArrayList<Integer>(); Long id = null; Number num = new Long( 3 );
Integer, Boolean .. , . API- , , , , .., .
, :
List<Integer> list = new ArrayList<Integer>();
:
List<int> list = new ArrayList<int>();
, , "" API- , , ( ) Vector Hashtable, ilk.
Vector
Hashtable
, NULL, , , # . null -1.
, , , (Double Integer Number).
., :1. . Number ( : Integer, Float ..) .2. null. , . , . , db NULL, .3. , , ( ). .4. , getHashcode(), toString() .., .