问题
When i user vector object in my blackberry app like below
Vector<Object> vector = new Vector<Object>();
i am getting compiler error as
blackberry parameterised are only available if source level 1.5
why is this error?
回答1:
BlackBerry is based on JavaME which is currently limited to Java 1.3 syntax. Thus, since generics were added in Java 5 (1.5), you are out of luck, unfortunately.
回答2:
Classes compiled for the BlackBerry must use version 1.3 of Java, which precludes things like generics and enums. On top of that, the classes that are supported are very limited and do not include the collections classes.
However, the BlackBerry does provide a number of custom collection classes that pre-date the standard ones. You may wish to use these if the facilities provided by Vector and Hashtable are not adequate.
回答3:
Generics/Parameterized types were added in Java 5.0 (2004) Before this version, the feature didn't exist.
IMHO Vector is a legacy collection which was replaced by ArrayList in Java 1.2 (1998) but is still supported. You should consider using ArrayList if you can.
来源:https://stackoverflow.com/questions/4945863/blackberry-parameterised-are-only-available-if-source-level-1-5