-
How to create an Array of TreeSet ?
Hello,
I am writing an application to solve the Sudoku puzzle and I need to create an array that will contain TreeSet objects. The TreeSets will contain String elements.
I have tried the following syntax without result (error messages follows the code):
private final int DIM2=9;
private Set<String>[] ligneGrille = new TreeSet<String>() [9];
private TreeSet<String>[] ligneGrille = new TreeSet<String>() [DIM2];
//array required, but java.util.TreeSet<java.lang.String> found
private Set<String>[] ligneGrille = new TreeSet<String>();
//incompatible tpes :
//found : java.util.TreeSet<java.lang.String>
//required: java.util.Set<java.lang.String>[]
Also, how would I access the TreeSet after it's created?
(Something like :
ligneGrille [0].add("6"); )
I am using NetBeans 4 as IDE.
Thanks for the help,
Pierre C.
-
Finally, this worked :
private Set[] ligneGrille = new TreeSet [DIM2];
for (int i = 0; i<DIM2; i++) {
ligneGrille[i] = new TreeSet<String> ();
}
Then, I could access it :
ligneGrille[indexX].add(aRemplacer);
Similar Threads
-
Replies: 4
Last Post: 04-14-2006, 09:09 AM
-
By Chris in forum Database
Replies: 3
Last Post: 08-20-2002, 12:14 AM
-
By Steve Oliver in forum VB Classic
Replies: 0
Last Post: 07-25-2002, 04:29 PM
-
By Mark Alexander Bertenshaw in forum VB Classic
Replies: 10
Last Post: 06-16-2000, 05:34 AM
-
By Ali Imran in forum Java
Replies: 1
Last Post: 05-06-2000, 11:58 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks