2D Arrays and Vectors (a wee bit urgent!)


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: 2D Arrays and Vectors (a wee bit urgent!)

  1. #1
    Join Date
    Feb 2003
    Posts
    17

    Talking 2D Arrays and Vectors (a wee bit urgent!)

    Hello all,

    I have a 2D Array that has the dimension 10x3

    What is the best way of putting this into a Vector. As I cannot use the finite sized arrays in my program.

    Can I declre a 2d vector ?

    How can I copy the contents of an Array into a Vector?




    Many thanks people.

    Scottie_GB






  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    You could make a class: RowColumnValue that only contains
    three ints, the rowNumber, the columnNumber and the value:
    Code:
    public class ColumnValue {
      public int row
      public int column=-1;
      public int value=0;
      public ColumnValue (int row, int column, int value) {
        this.row=row;
        this.column =column;
        this.value=value;
      }
    }
    Then you could loop through your array and store in an
    Arraylist (its supposedly better than Vector).
    eschew obfuscation

  3. #3
    Join Date
    Feb 2003
    Posts
    17

    Thankyou

    I will give this a go and see what happens.

    Cheers

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

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