DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2005

    Question How to create an Array of TreeSet ?


    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.

  2. #2
    Join Date
    Nov 2005
    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 :


Similar Threads

  1. Getting a GUI to run
    By Eric in forum Java
    Replies: 4
    Last Post: 04-14-2006, 09:09 AM
  2. Replies: 3
    Last Post: 08-20-2002, 12:14 AM
  3. Replies: 0
    Last Post: 07-25-2002, 04:29 PM
  4. SafeArrayCopy SLOWER than iterating string array!
    By Mark Alexander Bertenshaw in forum VB Classic
    Replies: 10
    Last Post: 06-16-2000, 05:34 AM
  5. 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
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.