G*********a 发帖数: 1080 | | g*****g 发帖数: 34805 | 2 I mean for ArrayList, for LinkedList, of course it's different.
I didn't see the source, but if you decompile it, I believe
you'll see something like that. | m******t 发帖数: 2416 | 3
There isn't a simple answer to this question. While it is safe to say int[]
is faster than most if not all the List implementations, the actual
difference depends the implementations, e.g., random access with ArrayList
is O(c), and O(n) for LinkedList.
【在 G*********a 的大作中提到】 : @@ : //bow
| c*m 发帖数: 836 | 4 How did you know? The source is open now?
【在 g*****g 的大作中提到】 : I mean for ArrayList, for LinkedList, of course it's different. : I didn't see the source, but if you decompile it, I believe : you'll see something like that.
| o***g 发帖数: 2784 | 5 yes, source of jse 5 is open now
【在 c*m 的大作中提到】 : How did you know? The source is open now?
| c*****t 发帖数: 1879 | 6 Yes.
1. int[] is only a single function call to set/retrieve a primary value.
2. List involves 2 (one to retrieve and one to get value from Integer
object. This is not counting the fact that List internally
may access an array itself using another function call. The list
algorithm may also be slower. There are maybe several logic checks as
well. In short, List has a lot more overhead costs.
When in doubt, read the source code :)
【在 G*********a 的大作中提到】 : @@ : //bow
| G*********a 发帖数: 1080 | 7 thanks! :)
//bow
【在 c*****t 的大作中提到】 : Yes. : 1. int[] is only a single function call to set/retrieve a primary value. : 2. List involves 2 (one to retrieve and one to get value from Integer : object. This is not counting the fact that List internally : may access an array itself using another function call. The list : algorithm may also be slower. There are maybe several logic checks as : well. In short, List has a lot more overhead costs. : When in doubt, read the source code :)
|
|