What is .intValue() in Java?

前端 未结 8 1395
暗喜
暗喜 2020-12-08 14:01

What is the difference between them?

l is an arraylist of Integer type.

version 1:

int[] a = new int[l.size()];
for (in         


        
8条回答
  •  再見小時候
    2020-12-08 14:35

    The Object returned by l.get(i) is an instance of the Integer class.

    intValue() is a instance method of the Integer class that returns a primitive int.

    See Java reference doc... http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#intValue()

提交回复
热议问题