+1 to blake's comments. A couple more points, inline:
blake wrote: > > Chris is right, that gets rid of the error, but I bet it is not what > bob is trying to accomplish. Chris' solution will create a Java array > of 9 Vectors. > > I have a couple of suggestions, here: > 1) Don't ever use Vectors. They are historical cruft. Use List and > ArrayList > In particular, the methods of 'Vector' are synchronized, which is often not what you want or need, and it contains legacy methods and members that are not compatible with the collections framework. 'Vector' has been out of date since 1998! It never ceases to amaze me that people still want to use it. I will bet dollars to doughnuts that the OP wasn't programming with Java yet in 1998. 2) Don't mix generics and Java arrays. It gets weird > That's putting it mildly. The Java Language Specification explicitly states, "... the element type in an array creation expression cannot be a parameterized type, other than an unbounded wildcard." (ยง15.10 http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#46168 ) > I suspect that what bob wants is > > import java.util.List; > > public class Oracle { > public static List<Article> articles; > public static void init(){ > articles = new ArrayList<Article>(9); > } > } > > ... and you can leave the "9" out, because the ArrayList will grow as needed... Note blake declares the variable 'articles' as type 'List' rather than an unnecessarily specific type, adhering to "Item 52: Refer to objects by their interfaces" from _Effective Java_ by Joshua Bloch. http://java.sun.com/docs/books/effective/toc.html Chris wrote: > >> articles = new Vector<Article>[9]; > > > > try articles = (Vector<Article>[]) new Vector[9]; > Again, neither of these is legal. You can get around it with '@SuppressWarnings', but shouldn't. The chapter on generics from _Effective Java_ [_op. cit._] is free to download and will help here. Take heed of "Item 23: Don't use raw types in new code". -- Lew -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en