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.

Similar Messages

  • 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 to declared an array of inner class ?

    can we declare array of inner class ?

    for example:
    Country.City.Airport.Flight[] fly = Country.City.Airport.Flight[VALUE];
    fly[0] = ( ( (new Country()).new City()).new Airport() ).new Flight();
    System.out.println(fly[0].toString());
    Class Country {
    Class City{
    Class Airport{
    Class Flight{
    }

  • 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/

  • 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 initialize Button Array at "declaration"?

    How to initialize Button Array at "declaration"?
    Button[] b = new Button[2];
    b[0] = "label" ?
    b[1] = "label" ?
    Again,please at declaration not using setText within main program.

    main...
    Button[] btts = {new Button(...),new Button(...), ...)
    that shold be it
                                                                                                                                                                                   

  • How to declare arrays?

    Hi!!
    I have one doubt.
    I need to declare one array with array size 10 , datatype string
    And with this i need to specify that the maximum length of each string should be 20.
    So is it String [10,20]
    i saw this in one book
    is this correct, if not can you tell me how to do this
    thanking you !!!

    So in a declaration string [][] we cant set the
    length of the string we are gonna insert in each
    space of array??No because using String[][] declares a two dimensional array (more correctly: an array of arrays) of Strings. Each String can still be as long as the maximum length of a string (theoretically Integer.MAX_VALUE characters).

  • 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 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 do I use arrays in web services?

    I have a function which returns an array of byte? How do I declare an array in Web services.

    public byte[] getBytes();

  • [Bash] How to `declare` a global variable inside a function?

    #!/bin/bash
    # Not using declare -A, array will be treated as indexed array rather than an associative array
    seta()
    for ((n=0;n<$1;n++)); do
    printf -v a_$n[k] %s k$n
    printf -v a_$n[j] %s j$n
    eval echo inside seta: a_$n[k] = \$\{a_$n\[k\]\}
    done
    seta 3
    echo outside: a_0[k] = ${a_0[k]}
    echo outside: a_0[j] = ${a_0[j]}
    echo
    # Use declare -A inside function, array will be undefined outside
    setb()
    for ((n=0;n<$1;n++)); do
    declare -A b_$n # Note here
    printf -v b_$n[k] %s k$n
    printf -v b_$n[j] %s j$n
    eval echo inside setb: b_$n[k] = \$\{b_$n\[k\]\}
    done
    setb 3
    echo outside: b_0[k] = ${b_0[k]}
    echo outside: b_0[j] = ${b_0[j]}
    echo
    # The bad solution, only works if we know beforehand how many c_? arrays will be assigned inside setc()
    for ((n=0;n<3;n++)); do
    declare -A c_$n
    done
    setc()
    for ((n=0;n<$1;n++)); do
    printf -v c_$n[k] %s k$n
    printf -v c_$n[j] %s j$n
    eval echo inside setc: c_$n[k] = \$\{c_$n\[k\]\}
    done
    setc 3
    echo outside: c_0[k] = ${c_0[k]}
    echo outside: c_0[j] = ${c_0[j]}
    My original code does the declare -A as in setb(). I was surprised when I saw all blank output... Now the problem is illustrated clearly by the setb() example.
    The setc() example works, but a bit ugly: look at the two 3's...
    My ideal solution would be, something like `declare_global -A b_$n` in setb()
    Any ideas?

    with current bash versions, i don't think it is possible to declare global associative arrays in functions.
    what you are after is the "-g" option of typeset which is available in zsh.
    i think i read somewhere that something similar may be planned for bash 4.2.

  • How to create an array?

    I know that when you create a new BPM object attribute you can choose an array in 10g. However, that just declares the array; I'm wondering how to allocate memory to it. I want to use it in a .jsp page for a list of fields. Also, what tag would I use to pass the parameters? i.e '<f: fieldName att="BPMObject.attribute"/>' is used for normal string variable attributes, what would I use for an array?

    Hi,
    Here is the code that you can write in your jsp page to iterate over an array.
         <c:forEach var="test" items="${bpmObject.bpmArray}" begin="0" varStatus="status" >
              <tr>
              <td align="center" width="25%">
              <c:out value="${test.arrayAttr1}"/></font></td>
              <td align="center" width="20%"><font size="2" face="arial">          
              <c:out value="${test.arrayAttr2}"/></font></td>               
              </tr>
         </c:forEach>
    Bibhu
    Edited by: Bibhuti Bhusan on Jul 19, 2011 8:13 PM

  • Rookie Question: Swap values? Declare an array and values of its indices?

    Hello,
    I hope this is the right forum: I have a simple Java Problem but i do not get it.
    Is like that: I have to swap values within an array e.g i have one array with 3 indices. Indice 0 (the first indice) has value 12. The middle indice has no value, and the second indice has value 9. How to swap 9 to 12 and 12 to 9 without direct swap, in other words, by using the middle indice that has no value or is zero? And how do i write it in an array?
    My other questions: How do i Declare an array and values of its indices?
    I hope this is the right forum or site at all, in cas enot, i hope you still can help or give me links that could help. I really need this.

    Hi Rookie,
         http://forum.sun.com is the best place to get answers for your queries.
         Answer to you first question:
         array[0]=array[0]+array[2]; // array[0] will have 21, because 9+12.
         array[2]=array[0]-array[2]; // array[2] will have 9, because 21-12.
         array[0]=array0]-array[2];  // array[0] will have 12, because 21-9.   
         Hope your first query is resolved.
         I will answer your next query in my next reply.
    Thanks & Regards,
    Charan.  

  • How to pass int array as an IN parameter to PLSQL Procedure

    Hi,
    How to pass int array in java to a stored procedure througn jdbc
    and what type of data type I should declare to this IN parameter
    in PLSQL Procedure.
    Thanks,
    Simi

    Hi,
    The best way to do what you want depends on what you want.  Start by describing what you need to do.  It's best to post some sample data (CREATE TABLE and INSERT statments) and what results you want from that sample data.  (See the forum FAQ: https://forums.oracle.com/message/9362002)
    If you have ideas about how to do the job (e.g., populating a temporary table) it can be helpful to include those, too, but distinguish clearly between WHAT you need to do and HOW you might do it.
    As Bencol suggested, a SYS_REFCURSOR might be the best way to pass back the results.
    Since you didn't post your table, or even describe what you wanted to do with it, I'll illustrate using scott.emp, which is probably on your system.
    Say you wanted a procedure that took a DATE as an argument, and returned a some designated columns (empno, ename and hiredate in the example below) for all employees hired on or after the given DATE.  You might write a procedure like this:
    CREATE OR REPLACE PROCEDURE  hired_since
    (   start_date  IN   DATE
    ,   out_data    OUT  SYS_REFCURSOR
    AS
    BEGIN
        OPEN out_data FOR
            SELECT  empno, ename, hiredate
            FROM    scott.emp
            WHERE   hiredate  >= start_date;
    END  hired_since;
    SHOW ERRORS
    You can test it in SQL*Plus like this:
    VARIABLE   c REFCURSOR
    EXEC  hired_since (DATE '1982-01-01', :c);
    PRINT :c
    The output I got from this test was:
         EMPNO ENAME      HIREDATE
          7788 SCOTT      19-APR-87
          7876 ADAMS      23-MAY-87
          7934 MILLER     23-JAN-82

  • Declaring an array

    Hi,
    Can you teach me how to declare and assign an array in oracle
    forms?
    Thanks.

    use the table data type,
    You can read more about it in the pl/sql guide on otn
    documentation section.
    or you can use a record_group, check out the online help of
    forms.

Maybe you are looking for

  • How to calculate Sub-Totals/Grand Totals on repeating row.

    I have a this form that I need to calculate to produce a Sub-Total....  An end user can keep adding a line item but I would like to be able to add the amounts entered to calculate in a sub-total field.  So basically, I need help with the actual scrip

  • How do I set up my 'author' page on iBooks?

    Can anyone tell me how to set up my 'author' page on iBooks?  I have three books, one from a major publisher, two from an independent, plus an audio program all listed, but no author page for any of them.  I'd like to connect them all together to a s

  • Application import falls over

    I'm using Portal 3.0.6.6.5 on 8.1.7 on Solaris. I'm trying to move my applications from development to a newly installed test environment. I've read the Import/Export pdf and have followed the order of exports/imports there. At the point where I run

  • RE: Org Structure in HR

    Hi Gurus, I am new to HR. I have ECC 6.0/windows 2003/oracle on my desktop. I am trying to create a Org Structure using PPOCE and when i saved it asked for the trasnport request. I have created this transport request. when i get out of T-code PPOCE a

  • Setting cursor on particular field

    Hi, Lets take two fields as field A and Field B. Based on the input given to field A, field B will be mandatory. So if Field B is not entered then it should show error message. Its working fine. but after displaying error message, the cursor should b