How to declare an expandable 2-dim Array

Hi,
How do I declare a 2-dim array that is can expandable with additional data?

Look at this example (Catching the ideas of the other guis:
e.g. create a Class Object which represents a Row
class Row {
ArrayList list = new ArrayList(10); //ten columns
public Object getObject(int x) {
list.get(x);
public void setObject(Object o, int x) {
list.add(x, o);
Create an Table Object which is able to add your Rows-Objects
class Table {
ArrayList rows = new ArrayList();
public void addRow(Row row) {
rows.add(row);
public Row getRow(int x) {
return (Row) rows.get(x);
public int getNrOfRows() {
return rows.size();
after this, you can fill your Objects like this
Row row = new Row();
row.setObject(0, "James");
row.setObject(1, "Kirk");
row.setObject(2, "Captain);
Table table = new Table():
table.add(row);
Hope it helps a little bit

Similar Messages

  • How to declare and initialize a STRING ARRAY (assign strings to array elements)

    How to declare and initialize a STRING ARRAY (assign desired strings to elements of an array, for example "abc", "def", "ghi", "jkl", etc.) in LabVIEW? I saw a "string array" block in help, but could not find it in the function palette. Does a spreadsheet string have to be in a file (or can it be in a string constant block)? Thank you.

    Hi,
    you can do it in several ways:
    1. Direct way: Create string array control on front panel and type strings in its elements
    2. Programmatically 1: Create string array indicator (or local variable of control), right click on it in block diagram, select "Create constant" from drop down menu. The array constant will appear. Now type values in this constant's strings
    3. Programmatically 1: Use "Build array", "Replace array subset", "Insert into array" or "Initialize array" functions from "Functions->Array" palette.
    And of course you can combine all of these methods.
    Good luck.
    Oleg Chutko.

  • How to fill up a 3-dim array?

    Hello!
    See the attached vi. We want to fill upp a 3-dim array. The pages are "number". If "true" is true then we want to insert the row that we build inside the case on page number "number". But the problem is that the new element is placed outside the 3-dim array because the pages are not the same size. How can this problem be solved? Maybe we should use "replace element" ? Does anyone have a tip or idea?
    Thank you and best regards.
    Attachments:
    trouble1.vi ‏51 KB

    Hello Ex-jobb,
    if you want to replace an element of an array, than the index has to be inside that array... Otherwise you have to add an element using build array.
    I changed your example a little bit.
    1) Adding a row with your "Replace Array element", but now using two index values. You may change the second index to your needs.
    2) Making the array constant "bigger" by setting a values at index [6,6,6]. You can NOT replace anything inside an empty array!
    Hope this helps,
    GerdW
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    trouble1.vi ‏51 KB

  • Create a 2-dim array dynamically

    Hello!
    I have had this problem here before but try one moore time :-)
    This is the thing: We have a text-file from which we read. This textfile can be different from time to time. From this textfile we can catch numbers of columns and numbers of rows that a 2-dim array should have. The problem is how one can create this 2-dim array dynamically? We have a while-loop that the program runs inside already. Must one use the while-loop to solve this problem? Or can one solve this with only a for-loop? Hope you understand how I mean :-) Best regards

    OK, I thought you want to read an array of the same size as the actual data in the file. You cannot read a 4x10 array if the file only contains data for a 3x5 array .
    Is the array size determined by the data in the file or by some other calculation?
    I would still read the entire file, then you can cut out a 2D subset using "array subset". This should not be a problem unless you have millions of array elements.
    LabVIEW Champion . Do more with less code and in less time .

  • How to declare a dynamic array in java

    I have to use a dynmic array of boolean and the size of this array will defiend throuh the run of the program to explian
    boolean[][] a;
    a=new boolean[number_of_ raw][number_of_ culm];
    after the program run the number_of_ raw and number_of_ culm will defind..so if any body know how to declare this kind of arraies in java please help me.

    My previous post gives me an idea on how to use ArrayList of ArrayList as dynamic 2 dimensional array.
    More info bellow
    ArrayList rows = new ArrayList()
    ArrayList columns_of_row0 = new ArrayList()
    rows.insertAt(0) = columns_of_row0;
    ArrayList columns_of_row1 = new ArrayList()
    rows.insertAt(1) = columns_of_row1;and so on..
    You can't use the code exactly or similar way, it would depend on how this array grows in your application.
    But this and my previous post should give an idea on how to insert and retrieve elements from ArrayList when
    treated as 2 dimensional array.
    Hope this helps.

  • How to Declare Arrays in bpel and use them as acollection

    Hi,
    I Am new to Bpel, I had created an empty Bpel Process and configured file adapter to a directory, In my text file i have 3 records with four columns, each column seperated by ',' and each record seperated by "EOL(end of line)", Below is the xsd file generated by the native format xsd builder, taken a recieve activity to recieve the contents of file from file adapter.
    So all the data which is in the file will be there in recieve activity.
    FileContents
    55555,rgfdgsd,gfdgfdg,23
    66666,retretret,trtertg,21
    77777,rtrttreter,trtter,23
    My Question is
    I want to compare whether value of C1 = '55555' and if the value is equal to 55555 then that record with c1=55555 has to be inserted into database by using Arrays
    How to compare the value of c1 through bpel functions.
    with java i have to use the logic similar to this by using Xpath
    getElement by tagname(c1);- it will give all the elements with tagname c1, three records are there with tagname c1 (c1=55555,c1=66666,c1=77777), we have to iterate through the elemnts and check whether the value iof c1='55555' and get the whole parent block which contains values of c1,c2,c3,c4 and insert that to database
    What variables we have to use to get the Similar logic in bpel
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    targetNamespace="http://TargetNamespace.com/FileAdapter"
    xmlns:tns="http://TargetNamespace.com/FileAdapter"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified" nxsd:encoding="ASCII" nxsd:stream="chars" nxsd:version="NXSD">
    <xsd:element name="Associates">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="Associate" minOccurs="1" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="C1" type="xsd:double" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="&quot;">
    </xsd:element>
    <xsd:element name="C2" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="&quot;">
    </xsd:element>
    <xsd:element name="C3" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="&quot;">
    </xsd:element>
    <xsd:element name="C4" type="xsd:double" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="&quot;">
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    I want to do it by using Arrays,
    Please post the step by step procedure like
    How to declare an Array?
    How to iterate the results in recieve acticity of file adapter and put them to array?
    How to compare the values in array with our desired value?
    Please Look into this and suggest me the solution.
    Regards

    I think it is a good option to use transformations. Do you have any critical reason why you want to do this using array?
    Little explanation below for your questions.
    As per my understanding from variable is the recieve activity variable and to variable is the Array variable is it right?
    Yes. Here I was try to build my array from the different source system data. This will append data to the array variable.
    How can we declare an array variable in bpel(to variable) with name as Variable_Array, part as payload and query as ArrayList?
    *Any element that can hold another element can be a array.
    For example if element A is declared as sequence of element B type, then A acts as a array for B*
    Could you please explain this also, what is from variable? and what is to variable?
    +<assign name="Assign_XPath_For_Array">+
    +<copy><from expression="concat('/ns1:ArrayList/ns2:ArrayElem') "/><to variable="Variable_Xpath"/></copy>+
    +</assign>+
    what is the type of to variable "Variable_Xpath"(String or int etc)?
    This creates a dynamic Xpath and store in some variable here. Here the variable is called Variable_Xpath which is a string
    similarly what is the type of to variable?
    +<assign name="Assign_Read_Array">+
    +<copy>+
    +<from expression="bpws:getVariableData('Variable_Array','payload',bpws:getVariableData('Variable_Xpath'))"/>+
    +<to variable="Variable_Read_Array_Element" query="/ns1: ABC"/>+
    +</copy>+
    +</assign>+
    To variable type is the variable that I read from the Array.
    *For example if A is the array holding B, then the to variable is B and from is doing A[counter]*
    Every Little Helps
    Kalidass Mookkaiah
    http://oraclebpelindepth.blogspot.com/

  • Please tell me how can  declare an array of object.

    how to create a two dimentional array object of a class.
    let,
    class abc{
    abc(){
    is it posible--
    abc ss=new abc[10][10]
    please tell me how can declare an array object.

    then always use String and don't consider
    StringBuffer at the outset. 'best practices' need not
    be seen as premature optimization. besides, if it is
    abstracted, does not matter how it is stored
    internallyNot sure I would agree with this example - a String is immutable, if I want to change the object then using a StringBuffer makes sense (conveys the intend, yada, yada, yada).
    Although, I do agree with you that some optimizations are best practices and should be used. I also come from the old days when optimization was always on our mind. Also, I would not expect someone to do something like re-calculate a value every time it is needed instead of storing the value in a variable, just to avoid optimization.
    I just think that the example of using a 1-dimensional array when a 2-dimentional array is a better representaion of the "real world" will both obscure the intention and compicate the code.

  • How do I find the total number of elements in a multi dim array

    How do I find the total number of elements in a single or multi dim array?
    For example, a 2x3 array has 6 elements, and a 2x3x4 has 24. How do I compute this very easily - is there a single VI that does this?
    David
    Solved!
    Go to Solution.

    Use "array size" (array palette) followed by "multiply array elements" (numeric palette)
    (Works also equally well for 3D arrays and higher)
    For a 1D array, just use "array size".
    Message Edited by altenbach on 02-05-2009 05:57 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    NumberOfElements.png ‏3 KB

  • In the attached vi, I have a 2-dim series of EMGs which I would like to connect with a 1-dim array. How can I do this?

    In the attached vi, de Y values are given for each time as a matrix. The problem is that the y values coming out have to be a 1-dim array, in order to connect this vi with another vi. How can I do this?
    Attachments:
    3-dim_Filter.vi ‏48 KB

    Hi,
    can you post your curve fitting .vi?
    I think you can do this with the reshape array.vi, and take the 2-D array, find out it's size, and multiply the two dimensions together to get the number of elements you need. That'll give you the array as 1-D, but whether it's in the correct order as you need it is another matter.
    It all depends on what the 2-D array is representing, and how much of it needs to go to the "other" .vi
    Hope that helps
    S.
    // it takes almost no time to rate an answer

  • How to declare an array

    Hi ,
    how do i actually declare an array of size 10 ? but i do not want to initialise the size which i will get after some processing
    String Array[];
    int arrysize ;
    arrysize = Getsize();
    so how to declare the size here
    pls help
    tks & rdgs

    how do i actually declare an array of size 10 ? but
    t i do not want to initialise the size which i will
    get after some processingWhat a strange question. How do you know that after some processing the size will be exactly 10? If you know then why not make it 10 right from the start?
    What you need probably is a dynamic array. That's an array that can grow to fit your needs. Java has one and it's called ArrayList. Check it out.

  • How to declare value binding to array list element in a pojo?

    I have a POJO called P, that contains an ArrayList member called w.
    class P {
    private ArrayList w = new ArrayList(5);
    w is initied in the class constructor.
    The POJO is in the SessionBean and I would like to reference individual
    elements in the ArrayList via a value binding like so;
    #{SessionBean1.instanceOfP.w[5]}
    I'm not sure how to declare the getter/setter for member W in POJO P
    so that setter and getter injection work.

    You may not be able to directly set the indexed value.
    Try some thing like this.
    Add a property that returns the indexed value.
    Ex. if you ArrayList objets are of type "String"
    int index = 5;
    public String getMyValue(){
    return w.get[index]
    Now your value binding would look something like
    #{SessionBean1.myValue}
    BTW, if you want to access different index, create another method
    public void setIndex(int index){
    this.index = index;
    - Winston
    http://blogs.sun.com/roller/page/winston?catname=Creator

  • How to sort a 2 dim Array ?

    hello
    I would like to sort a 2-dim array of double ( double[][])
    according to the 1st column
    It is possible to sort a 1st dim array (doubel[]) , but the method sort
    of the class Array doesn't work with double[][]).
    I have two (bad) solutions.
    1) Writing a sorting method but I would prefer using the sort' method of java which uses quicksort
    2) Creating a table of objects that implements Comparable but this would decrease performance
    Do you have a better Idea ?
    Thanks a lot

    I would like to sort a 2-dim array of double (double[][]) according to the 1st column
    Which is the first "column"? double[0][x] or
    double[x][0]?
    If it's the second one things get simple: your
    double[][] is really an array of objects where each
    object is an array of doubles. So all you need to do
    is write a custom Comparator for double[] to use the
    sort method:
    compare(Object obj1, Object obj2) {
    double[] d1 = (double[]) obj1;
    double[] d2 = (double[]) obj2;
    return d1[0] > d2[0];
    }Thanks for your so prompt answer.
    I can manage to put the data so that I sort the array according to x as in double[x][0]?
    But WHERE do I have to write the "compare" method ?
    Thanks

  • System.arraycopy (2 dim array) and growth of 2 dim array

    Hi everybody
    I am working on a program which contains a module that can perform Cartesian product on number of sets.
    The code I have developed so far is :
    import java.lang.reflect.Array;
    public class Cart5 {
    public static void main(String[] args) throws Exception
    int pubnewlength;
    // declare SolArray
    int[][] solArray;
    // initialize solArray
    solArray=new int[1][4];
    // Use for method
    for (int ii=0 ; ii<4 ; ii++)
    solver(solArray,ii);
    // Print the array ?
    System.out.println("\n  The array was changed ... " );
    }  // End main
    public void solver(int Solarray2[][] , int abi)
    int[][]  A  =  {  {1,2,3,5},
                      {4,6,7},
                      {11,22,9,10},
                      {17,33}
      jointwoArrays(solarray2,A,abi);
    // some other operations
    } // End Solver method
    public void jointwoArrays(int solarray3[][] , int aArray[][],int indexA)
    int y,u;
    int[][] tempArray;
    // calculate growth of rows:
    pubnewlength=solArray3.length * aArray[indexA].length;
    //Fill TempArray
    y=solArray3[0].length;
    u=solArray3.length;
    tempArray=new int[u][y];
    // Use system.arraycopy to copy solArray3 into tempArray -- How ?
    // Change the size of arrow to proper size -- How ?
    solArray3 = (int[][]) arrayGrow(solArray3);
    // Join operation - Still under construction
    for(int i = 0, k = 0; i < tempArray.length; i++)
                   for(int j = 0; j < set3.length; j++)
                                     for (q=0;q<=2;q++)             
                                      { solArray3[k][q] = tempArray[i][q];}
                                     solArray3[k][q]= aArray[indexA][j];
                                     ++k;
    } // End jointwoArrays method
    // This module is from http://www.java2s.com/ExampleCode/Language-Basics/Growarray.htm
        static Object arrayGrow(Object a) {
        Class cl = a.getClass();
        if (!cl.isArray())
          return null;
        Class componentType = a.getClass().getComponentType();
        int length = Array.getLength(a);
        int newLength = pubnewlength;
        Object newArray = Array.newInstance(componentType, newLength);
        System.arraycopy(a, 0, newArray, 0, length);
        return newArray;
    } // End ClassI deeply appreciate your help with these 3 questions :
    1. How can I use system.arraycopy to copy my two dimensional array? I have searched but examples seem to be about one dim arrays.
    2. How can I change the "static Object arrayGrow(Object a)" , to grow my two dimensional array ?
    3. If you know any codes or articles or java code regarding cartesian products , please tell me.
    Thank you
    Denis

    1. How can I use system.arraycopy to copy my two
    dimensional array? I have searched but examples seem
    to be about one dim arrays.That's because you can't do it in one call. You need to create a loop which copies each 'row".
    >
    2. How can I change the "static Object
    arrayGrow(Object a)" , to grow my two dimensional
    array ?Why do you make it so complicated (generic). Make it take an int[][] array instead, and see the answer from above.
    >
    3. If you know any codes or articles or java code
    regarding cartesian products , please tell me.There are probably lots of them if you google.
    Kaj

  • How to extract every component in an array?

    Hello everyone!
    Do you know how to extract every component from an array field?
    For example:
    The following is the defination of a table:
    CREATE TABLE test (
    id NUMBER PRIMARY KEY,
    name VARCHAR2(32),
    shape MDSYS.SDO_GEOMETRY
    And then I insert a new record:
    INSERT INTO test VALUES(
    1,'first',
    MDSYS.SDO_GEOMETRY(
    2003,
    NULL,
    NULL,
    MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),
    MDSYS.SDO_ORDINATE_ARRAY(1,1, 5,7)
    The Question is I want to read the every component (for example 1,1,5,7) in the sdo_ordinate_array one by one. Who knows how to write the SQL?
    I have tried "select a.shape.sdo_ordinates(1) from test a". But it can't work.
    Thank you very much!

    One solution is to read each ordinate from a cursor ina SQL block. Here is an example:
    set serveroutput on
    SET serveroutput on SIZE 1000000
    set concat on
    DEFINE layername = 'LAYER';
    DEFINE geomcolname = 'GEOM';
    DECLARE
    id varchar2(10);
    longitude number;
    latitude number;
    logmile number;
    i number;
    theLayer varchar2(32);
    theGeomCol varchar2(32);
    BEGIN
    FOR rec IN (SELECT ROWID, id, &geomcolname FROM &layername ) LOOP
    id := rec.id;
    i := 1;
    while i < rec.geom.sdo_ordinates.count loop
    longitude:=rec.geom.sdo_ordinates(i);
    latitude:=rec.geom.sdo_ordinates(i+1);
    logmile:=rec.geom.sdo_ordinates(i+2);
    dbms_output.put_line(id || ',' || longitude || ',' || latitude || ',' || logmile);
    i := i + 3;
    end loop;
    END LOOP;
    commit;
    END;
    Maybe that will help.
    Dave
    David R. Miller
    Michael Baker Jr., Inc.
    3601 Eisenhower Avenue
    Alexandria, VA 22314
    [email protected]
    www.mbakercorp.com

  • Sort a 2-dim array?

    Hello!
    Now we have the following problem: We need to sort a 2-dim array depending on the values in the first column. Then we need the corresponding row to move to the right place too... we send a VI so you can see an example of how it might look like. So we need (in this case) the first column to sort so we get 1,2 and 3 and so on, so the last row should be 3,4, 392 and 2047.
    We think this might be easy to solve but we need some tip :-) Thank you and best regards.
    Attachments:
    sortarray.vi ‏17 KB

    I wrote my own 2D string array sort routine. It has come in handy many times. You can enter the column number that you want to sort on, and the entire rows are rearranged in the order of the column sort. If your array is numeric, you can easily change the vi to use numerics instead. One day I hope to make it polymorphic. Here it is:
    - tbob
    Inventor of the WORM Global
    Attachments:
    Sort2DArray(str).vi ‏63 KB

Maybe you are looking for

  • I bought an iPhone 5 off of craigslist, which unbeknownstome was stolen

    Before I start, I just want to let everyone know that I know exactly what most of you will say, but I beg you to read this with an open-mind and understand where I'm coming from and my position. I am also a victim in this situation, just like the gir

  • Product costing valuated sales order stock

    Hi all, We are in complex mfg & currently re-vamping all the ERP SAP instances ( totalling 13 company codes into one single) All 13 units( who use NON Valuated scenarios for cost object controlling) wil use valuated sales orders & projects. The old 1

  • Doubt Regarding Materialized View

    Hello, I am working on Oracle 10g. We have multiple materialized Views which we Refresh in every 15 mins. My question is that can we get data from these MV's for a particular date....??

  • Unexpected NFSv4 permissions behaviour

    I used to successfully mount my Arch desktop drives on my Ubuntu laptop, using NFS. Recently I switched my laptop (which is my production machine for work) to Arch as well. Since the desktop is configured as the NFS server, I assumed it was simply a

  • Nomad Zen Xtra prob

    Well, I just emailed support again but overlooked the (faster?) forums until now. Maybe someone can help me out... ------- EMAIL SENT -------- Hi, I emailed the customer support a while ago and got a generic reply as how to reset my mp3 player's OS.