Incrementing an array variable!!!

Hello,
I wanna know if we can increment an array variable by more than 1.
When I use for(i=0;i<10;i+4) it is giving me an error.Just wanted to know if we can increment an array variable by any value other than 1.
Thanks

Your are right, I see that thank you
Ok sorry guys for pasting the assignment. I have done some thing but me not sure weather I am doing right way or not. here is my code. And by the way how to return the integer to the main function "public static void main(String args[]){" from static integer function "static int isCentered(int[] a){"
Code for Q. 1)
Out put:
{1,2,3,4,5} => 0(the middle element 3 is not strictly less than all other elements)
{3,2,1,4,5} => 1(the middle element 1 is strictly less than all other elements)=>
{3,2,1,4,1} => 0(the middle element 1 is strictly less than all other elements)
{3,2,1,14,6} => 0(no middle element since array has even number of elements)
{} => 0(no middle element)
{1} => 1(satisfies the condition vacuously)
import java.io.*;
public class isCenteredArray{
public static void main(String args[]){
isCentered(new int[]{1, 2, 3, 4, 5});
isCentered(new int[]{3, 2, 1, 4, 5});
isCentered(new int[]{3, 2, 1, 4, 1});
isCentered(new int[]{3, 2, 1, 1, 4, 6});
isCentered(new int[]{});
isCentered(new int[]{1});
static int isCentered(int[] a){
int ar=0;
if(a.length%2 ==0){
  return ar;     
int j=1;     
for (int i=0; i<a.length; i++){
if(j != a.length/2){
if(a[i] > a[a.length/2]){
ar = 1;
}else{
ar = 0;
return ar;     
j=j+1;     }     
return ar;           
Code for Q. 2)
Out put:
{1,2,3,0} => 1(because 1+2 = =3+0= =3)
{1,2,2,1,3,0} => 1(because 1+2 = =2+1= =3+0= =3)
{1,1,2,2} => 0(because 1+1 = =2 != 2+2)
{1,2,1} => 0(because array does not have any even number of elements)
{} => 1
import java.io.*;
public class isDualArray{
public static void main(String args[]){
isDual(new int[]{1, 2, 3, 0});
isDual(new int[]{1, 2, 2, 1, 3, 0});
isDual(new int[]{1, 1, 2, 2});
isDual(new int[]{1, 2, 1});
isDual(new int[]{});
static int isDual(int[] a){
int ar=0;
for(int i=0; i<=a.length; i++){
if(i%2 !=0){
if((a[i-1] + a) == a[i+1]){
ar = 1;     
}else{
ar = 0;     
return ar;
return ar;     
Code for Q. 3)
Out put:
{1} => 1(true vacuously)
{2} => 0(contains no odd elements)
{1,1,1,1,1,1} => 1
{2,4,6,8,11} => 1
{-2,-4,-6,-8,-11} => 0
import java.io.*;
public class idOddHeavyArray{
public static void main(String args[]){
isOddHeavy(new int[]{1});
isOddHeavy(new int[]{2});
isOddHeavy(new int[]{1, 1, 1, 1, 1, 1});
isOddHeavy(new int[]{2, 4, 6, 8, 11});
isOddHeavy(new int[]{-2, -4, -6, -8, -11});
static int isOddHeavy(int[] a){
int ar=0;
int oddheavynumber=0;
for (int i=0; i<a.length; i++){
if(a>oddheavynumber){
oddheavynumber = a[i];     
     }else{
oddheavynumber=oddheavynumber;          
if(oddheavynumber%2==0){
ar=0;     
     }else{
ar=1;          
System.out.println(ar);
return ar;          
Please check the way out how I did and let me know if I am going the wrong way...
Thanks,
Indoman

Similar Messages

  • How do I use an array variable in the assignment target?

    Hi,
    I am creating a BPEL process in which I have to use an array variable. The array variable needs to be initialized based on some condition.
    The issue is I cannot find a way to set the value of the array variable. There are ways to GET the value of an array variable indexing into it.
    But how do I set the value by using the Array variable in the <to> tag?
    Any help is appreciated. I am using BPEL 10.1.2.0.2.
    Thanks.

    You can declare a variable of type integer which will server as your index. Figure out based on some condition in your process which index of array to update. Assign to your integer variable you created.
    And have Assign copy operation like this -
    <copy>
    <from variable="Var_Output_FetchDueDate"
    part="OutputParameters"
    query="/ns18:OutputParameters/ns18:DUEDATE"/>
    <to variable="outputVariable" part="payload"
    query="/client:GetCustomerAccountInformationProcessResponse/client:customer/client:accounts/client:account[$Var_Counter]/client:dueDate"/>
    </copy>
    I have been using this in my processes.

  • How do I load values from a database column to an array variable in TS?

    I'm trying to get the values from the column in a database into an array variable in TS using the property loader.
    The Open Database, Open SQL Statement, and Property loader steps all complete and say "done".  But my array is empty when it's all over.
    Using TestStand 2010
    Microsoft SQL Management Express 2008
    Database configured by my company, I can not change it only read from it.
    Thank you,
    Newb-D

    The database has to be in a form that will work with the PropertyLoader and it sounds like it isn't.
    Try using the Import/Export Properties tool found in the Tool menu, to export some data to a database and then you can see if your database is compatible.
    My guess is you will have to write your own loader.
    Regards
    Ray Farmer

  • How to use array variable in Oracle

    Hi,
    I want to use a array variable to store many string values i.e. values like ( "my name is hhhyy and i have a tack", "My data is valid" , "hhggg gaya hujjjs")
    currently all these values are in seperate variables , I want to consolidate them in one array and use it in further , after replacing some values from them.
    I want to take data too. I am thinking of using "Varchar array" with values are in one cursor i want to take them in single array.
    varchar array is throwing some exception once it has taken all the value. I had extended it upto 100 values.
    What could be the possible solution.
    create or replace function testet
    ( value varchar2) return varchar2
    as
    x_value Varchar2(2000);
    x_value2 varchar2_array := varchar2_array();
    x_value3 number;
    cursor c1 is
    SELECT val
    FROM table A
    WHERE A.coulmn= 'val';
    begin
    x_value2.EXTEND(100);
    x_value3 := 1;
    for indx IN c1
    loop
    x_value2(x_value3):= indx.val;
    dbms_output.put_line(x_value2(x_value3));
    x_value3 := x_value3 + 1;
    end loop ;
    end;

    user12403816 wrote:
    actual error :
    ORA-06533: Subscript beyound count
    ORA - 06512 " at Function name , line 23
    ora - 06512: at line 3
    06533, 00000, "Subscript beyond count"
    // *Cause:  An in-limit subscript was greater than the count of a varray
    //          or too large for a nested table.
    // *Action: Check the program logic and explicitly extend if necessary.code contains bug.
    after code is fixed, then no error gets thrown

  • Working with array variables defined in the BPM process

    Hello,
    I have created an array variable in my process. This array was created based on a custom type that contains 2 strings variables.
    How can I set/get and add new items to this array variable using java code?
    The only thing I know is that, if this was a simple variable I would do something like this:
    DCBindingContainer bc = (DCBindingContainer)FacesContext.getCurrentInstance().getApplication().evaluateExpressionGet(FacesContext.getCurrentInstance(), "#{bindings}", BindingContainer.class);
    JUCtrlAttrsBinding dc = (JUCtrlAttrsBinding) bc.findNamedObject("myVar");
    dc.setInputValue("theValue".toString());
    thank you
    fwu

    Hi
    I've been working on TZ's recently... see this post:
    https://supportforums.cisco.com/discussion/12474756/how-check-daylight-saving-within-uccx-script
    My approach in the scripts was that basically I allow the department to set their opening hours in the timezone of their choice.
    They have a management web page served from CCX that accepts start/end times each day, and a timezone. That all gets stored in XML.
    In the script, based on that information I get the current time in whatever timezone is set, and compare that to the XML open/close times.
    Similarly for holidays, I get the current date/time in the holiday TZ and compare the holidays to that.
    Aaron

  • How to use array variable in Business Rule

    Hi,
    I have read a lot about Array variable. But everywhere declaration of array variable in described. I can declare that. It works fine. But i can't implement that array variable.
    Can any one please provide me an example of implementation of array variable?
    Regards,
    Rubi
    Edited by: Rubi Banerjee on Mar 30, 2012 3:35 AM

    forget about all varible in essbase CSC
    it's bad practics.^^^Is it?
    Essbase cube are self big array )^^^That's what makes ARRAY so cool -- you can set up an array that encompasses a dimension.
    Example straight from a HBR:
    ARRAY SomeArray["Entity"] ;
    Regards,
    Cameron Lackpour

  • How to create an array variable

    Hi folks,
    I'm developing a flowN activity , for each branch created, I need to pass different values (values I get from DB).
    For this my plan would be,
    -create an array variable , load all the values(from DB) into the array
    -pass the array to each branch in flowN activity based on the index
    As I'm newbie to BPEL, I do not know how to create an array variable.
    Could you people guide me please.
    Regards
    Viki

    Hi,
    I created my string array like
    <element name="string_array">
    <complexType>
    <sequence>
    <element name="input" type="string" minOccurs="0" maxOccurs="unbounded"/>
    </sequence>
    </complexType>
    </element>
    <variable name="arr" element="client:string_array"/>
    I am able to add values to my array variable named as "arr"
    When I use the following code snippet, it gives my the value of the entire list.
    <%ora:getNodeValue(bpws:getVariableData('arr'))%>
    But when I try retireve values one by one like <%ora:getElement('arr','/client:string_array/client:input',[0])%>, its giving me error.
    Guide to get throu' this.
    Viki

  • Increment a Char Variable

    How do you increment a character variable?
    Eg.
    DATA: L_VAR1(3) TYPE C,
              L_INC(3) TYPE C.
    L_VAR1 = '080'
    L_INC = '001'.
    Then I need in a particular Loop run, L_VAR1 to vary from 080, 081, 082...120.
    If I increment it with L_VAR1 = L_VAR1 + L_INC.
    The next value stored is 81 and not 081.
    Please provide Inputs in2 this.
    Thanks

    Hi..
    Since u need a numeric value. Declare with Type N.
    Eg:
    DATA: L_VAR1(3) TYPE N,
    L_INC(3) TYPE N.
    L_VAR1 = '080'
    L_INC = '001'.
    Then:
    L_VAR1 = L_VAR1 + L_INC.  "This will work.
    <b>
    REWARD IF HELPFUL.</b>

  • Passing Array variables between objects

    While troubleshooting a Flash app, it took me hours to figure
    out that you need to make a duplicate of an Array variable if you
    are passing it between objects. Otherwise, any alterations that you
    make to the array will result in the original array being altered
    as well as the "new" array.
    I'm no developer, can someone please explain why you have to
    do this? Or, give me an instance when you wouldn't want to make a
    duplicate? Just trying to understand.
    Thanks.

    it is because if you do something like this
    a=[1,2,3]
    b=a
    all you are doing is storing a reference to a in a variable
    b.Instead, either copy oput the array again or use one of the array
    methods which return an array eg
    b=a.slice()
    b=a.concat()

  • Xsql:set-page-param from multirow select into array variable

    I'd like to set an XSQL page array variable to the result of a query that returns multiple rows.
    Can I do something like this:
    <xsql:set-page-param name="users[]">
    select username from all_users
    </xsql:set-page-param>
    The documentation only mentions usage like
    <xsql:set-page-param name="users[]" value="SCOTT SYS SYSTEM"/>

    The set page param is only designed to look at the first column of the first row of its query results.
    If you supplied a PL/SQL function that would return the list of users as a space-or-comma-separated string, then you could use:
    select your_function() as user_list from dual
    and then add the treat-list-as-array="yes" attribute to achieve this.

  • Problem with arrays - variable not been inicializes

    I've declared my array ;
    int[] array ;
    int intefer;
    BufferedReader stdin = new BufferedReader(new InputStreamReader( System.in ));
    intefer = stdin.readLine();
    array[0] = intefer; --> variable array might not have been initialized.
    Can you please help me ? Why is the error occuring ?

    array[0] = intefer; --> variable array might not have been initialized.
    Can you please help me ? Why is the error occuring ?An array is an object; all object should be instantiated by use of the 'new'
    operator. You never instantiated such an object and therefore never
    initialized your 'array' variable.
    kind regards,
    Jos

  • Load array variable from external xls file

    I want to initialize an array variable using an external xls file.
    I am trying with property loader step but I have to insert manuallly all the elements of the array.
    Is there any other way to do this?
    Thanks
    Valter

    Hi FiloP
    When i open and close your example in my Teststand (Engine and Editor 4.0.0.326) Teststand asked me to save
    some NI-Tpyes.ini !!!
    That means my TS NI Types from release date: 2007-April-05 differes from yours.
    There could be to two reasons: your files are conterminated or NI have relased a new update with newer step-types.
    So until this not clear everbody should be carefully. Never acept savings to NI-Types when closing.
    To get more information about this please visit this thread:
    http://forums.ni.com/ni/board/message?board.id=330&message.id=17427#M17427
    greetings from the lake of Constance, Germany
    and get never affected by a type virus
    juergen
    HI Valter1,
    tomorrow evening i will post a C# example.
    greetings
    juergen
    =s=i=g=n=a=t=u=r=e= Click on the Star and see what happens :-) =s=i=g=n=a=t=u=r=e=

  • How to use event to detect the change of a array variable?

    I have a main application that includes a lot of sub
    components. the main app mxml file import a public class that
    includes an array variable. Each of the values in the array can be
    updated in the sub components.
    I would like to have the main mxml be able to detect the
    change of the values of the array. Is it possible to use event? And
    how? Is there a good example to follow?

    See this FB3 help topic, particularly watchers:
    Defining data bindings in ActionScript

  • Help increment through array elements to print

    I am to create an amortization program to list the month, year, payment, interest, and balance. Everything works except the year increments by 1 on every loop (it should increment only when month is January), and the array of months prints the entire 12 months in one column. I need to print one month then tab to the year, then the rest. Here is a sample output.
    Mortgage Payments
    Financial Details
    Loan Amount: $200,000.00
    Payment Amount: $1,167.15
    Term (in years) 30
    Term (in months) 360
    Interest Rate: 5.75%
    Payments are $1,167.15 per month
    Month Year Payment Amount Interest Amount Balance
    January
    February
    March
    April
    May
    June
    July
    August
    September
    October
    November
    December
    monthcount =1 // some variable I added to watch monthcount...will remove later
    2004 $1,167.15 $607.89 $198,832.85
    January
    February
    // and it starts over
    Here is the method to create array:
    void printBody() {
    finalyear = printyear + TERM;
    do {
    balance = balance - payment;
    intAmount = payment - (payment * RATE) * 100;
    DecimalFormat dollarFmt = new DecimalFormat("$###,###.00");
    MortgagePmt prtmo = new MortgagePmt();
    String monthPrint[] = {
    "January", "February", "March", "April", "May", "June", "July",
    "August", "September", "October", "November", "December" };
    for (int i = 0; i < monthPrint.length; i++)
    System.out.println("\n" + monthPrint);
    ++monthcount;
    if (printmonth < 2)
    ++printyear;
    System.out.println("monthcount =" + monthcount);
    System.out.println("\t" + printyear + "\t" + dollarFmt.format(payment)
    + "\t" + dollarFmt.format(intAmount) + "\t" + dollarFmt.format(balance));
    while (monthcount <= finalyear && balance <= AMOUNT && monthcount <= totmonths);
    Then, I simply call "printBody()" from Main.
    I want the output to be:
    January 2004 $1,167.15 $607.89 $198,832.85
    February 2004 $1,167.15 $607.89 $19x,xxxx,xx
    and so on.... for the life of the 30 year mortgage.
    Can anyone give me an idea of what to do to accomplish this? I started out originally using case statements (each month was a different case); however, I couldn't figure out how to make the case increment because it would only print one element each time. Same problem.
    Any help would be greatly appreciate. It's for my Java class and I am stuck!

    use a loop and
    while(i < 360)
       System.out.println(value);
    i++;

  • Problem in using array variable in PartnerLinks

    I have a stored procedure in Oracle DB,which the parameters is a varray with types,such as
    type temp1 as object (temp_id varchar(10),temp_desc varchar(512));
    TYPE templist AS VARRAY(50) OF TEMP1
    procedure testArray1(accounting_temps IN templist)
    I used the database adapter to generate a partnerlink,it can work,but when I assign the variables to DBAda1_InputVariable (using while to read all data in xml),it only send a array with one value,the last value updates the value before.
    How to add the array (not update) variable in this case??
    Thanks and best regards!!

    I have a stored procedure in Oracle DB,which the parameters is a varray with types,such as
    type temp1 as object (temp_id varchar(10),temp_desc varchar(512));
    TYPE templist AS VARRAY(50) OF TEMP1
    procedure testArray1(accounting_temps IN templist)
    I used the database adapter to generate a partnerlink,it can work,but when I assign the variables to DBAda1_InputVariable (using while to read all data in xml),it only send a array with one value,the last value updates the value before.
    How to add the array (not update) variable in this case??
    Thanks and best regards!!

Maybe you are looking for

  • W540 fails to boot

    Turned on my W540 running Win 8.1 and it has started going straight to a blue screen that says the Boot Configuration Data File doesn't contain valid information for an operating system. No logical explaination as to why this has happened. So first I

  • Acquisition tax in Belgium/Germany-Posting with different tax codes

    Dear Friends, Does anyone have experience working with Acquisition tax in Belgium and German where the goods and services purchased within EU have 21% -input and output tax such that it is ZERO. But still Tax authorities need to see both input and ou

  • Baseline date in MIR7 cannot be refreshed

    Dear experts, I've got a question in using MIR7 to park invoice. I found that if I changed the document date, the baseline date cannot be refreshed automatically. It leads a result that the net due date is calculated wrongly. So I would like to know

  • Can't connect iphone 5 to ipad 3 by bluetooth for hotspot

    I have an iPad 3 4G and an iPhone 5. Both data plans allow me to use personal hotspot, and depending upon which carrier has the better signal, I used to be able to use the other devices data plan. Recently (since updating to IOS 6.0.1) I can no longe

  • Uploading into database table from text file using tab (GUI_UPLOAD)

    i have small doubt i have 3 fiels in text file using tab as separator i need to update into database table 'ZABPSP_01' from 's.txt' located in local disk. My code is below. Please let me know the correction. Awaiting for ur response. Thanks in advanc