问题
The Blackberry JDE does not include java.util.ArrayList
, even though it knows about java.util
? What's up with that? Is there an equivalent class for BB? I don't want to use an array, really, because I have an unknown number of objects I'm dealing with. why does the Blackberry JDE leave so much out?
回答1:
Well they are Java from a language standpoint. It just doesn't support all of the standard edition packages. It falls more inline with the microedition standards, but is way beyond J2ME from a package standpoint. They don't go around saying they're in compliance with J2SE 1.6, but it's still Java.
And of course it has arrays, unless you mean the class, Arrays
. But, they have that too. It's located in package net.rim.device.api.util
.
回答2:
Yeah, Blackberry isn't J2SE, but it's not J2ME neither. Check out:
- IntVector
- SimpleSortingIntVector
- IntStack
- ByteVector
- UnsortedReadableList
- SortedReadableList
I have doubts about impossibility of doing with those classes something you can do with ArrayList.
Great article: BlackBerry API Hidden Gems (Part Two)
回答3:
You can add it into your package yourself. Get the ArrayList implementation and just add it into your project. You will also need to get the implementation for AbstractCollection, AbstractList, Collection, Comparable, ConcurrentModificationException, Iterator, List and ListIterator.
I have a project that has a java.util package and I have put all of these classes in there and I can now use ArrayList :). You will have to modify the classes slightly to use rim imports rather than standard java imports where necessary, but it can be done if you really want ArrayLists.
来源:https://stackoverflow.com/questions/1428891/blackberry-jde-arraylist