Changing variable name within loop

Instead of typing oit 8 different versions of this loop, I'd like to do something this where i increases value to define a new variable:
for (int i = 1; i < 9; i++)
            double lbs[i] = (((dis * 2000) / 3456) * (ve)) * pr * 0.069 / 100;
            BigDecimal bd[i] = new BigDecimal (lbs);
bd[i] = bd[i].setScale (1,BigDecimal.ROUND_UP);
lbs[i] = bd[i].doubleValue ();
String tflow[i] = Double.toString (lbs[i]);
oFlow[i].setText (tflow[i]);
i++;
In PHP that's how I do it, but how about Java? I tried searching for "variable variables" since that's the only want I know how to describe it.

I put what you gave me inside of public void CalcBoost() { ... } and I'm getting the error:java.lang.NullPointerException
        at Calculator.CalcBoost(Calculator.java:751)
        at Calculator.iBoostActionPerformed(Calculator.java:672)
        at Calculator.access$700(Calculator.java:69)
        at Calculator$8.actionPerformed(Calculator.java:299)
        at javax.swing.JTextField.fireActionPerformed(JTextField.java:491)
        at javax.swing.JTextField.postActionEvent(JTextField.java:672)
        at javax.swing.JTextField$NotifyAction.actionPerformed(JTextField.java:786)
        at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1530)
        at javax.swing.JComponent.processKeyBinding(JComponent.java:2438)
        at javax.swing.JComponent.processKeyBindings(JComponent.java:2473)
        at javax.swing.JComponent.processKeyEvent(JComponent.java:2401)
        at java.awt.Component.processEvent(Component.java:4909)
        at java.awt.Container.processEvent(Container.java:1569)
        at java.awt.Component.dispatchEventImpl(Component.java:3615)
        at java.awt.Container.dispatchEventImpl(Container.java:1627)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1713)
        at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:627)
        at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:831)
        at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:741)
        at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:592)
        at java.awt.Component.dispatchEventImpl(Component.java:3506)
        at java.awt.Container.dispatchEventImpl(Container.java:1627)
        at java.awt.Window.dispatchEventImpl(Window.java:1606)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:480)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)This now points to: for (int i = 0; i < oFlow.length; i++)

Similar Messages

  • How to Edit names within Loop Library

    I've edited a MIDI Apple Loop from Jam Packs and saved it as an MIDI Apple Loop in the library.
    What I typed in as a name for the file is not what appeared in the loop library?
    1. Why did the text alter from I typed?
    2. How can I edite the name in the within loop library.
    3. How do I delete apple loops I've created from the apple loop library?
    Thank you
    - I did look in the manual and within the user help in Logic, but could find nothing. I know I must be looking under the wrong 'key word' search.
    What can I say!
    Message was edited by: StyleSupport

    StyleSupport wrote:
    1. Why did the text alter from I typed?
    You must select the green loop in the Arrange and go to Region menu "Add loop to the library" something like that or drag and drop the region to the Library in the Media dock.
    This way a new dialog will show( see the picture below ) where you need to fill new "unique" name or to add some user (sub name), choose the group etc.
    2. How can I edite the name in the within loop library.
    3. How do I delete apple loops I've created from the apple loop library?
    You "user" green loop is stored to ...user/Library/Audio/Apple Loops/User Loops.
    Browse to this dir and edit or delete the loop.
    You "user" green loop is stored to ...user/Library/Audio/Apple Loops/User Loops.
    Browse to this dir ( you will find a folder labeled as "Single" or something like that open it ) and edit or delete the loop in question.
    !http://img42.imageshack.us/img42/508/greenloops.gif!
    !http://img59.imageshack.us/img59/4967/aglogo45.gif! [www.audiogrocery.com|http://www.audiogrocery.com]

  • Change variable name of component once declared

    Hello,
    I was wondering if you can change a variable name of a component so if i had the following declaration of a button like this:
    JButton btn = new JButton();can i then change the variable name 'btn' to be 'button' after i have declared it like this ?
    Many thanks in advance

    ok, you might have a better solution for me actually....
    What i have done so far is created a JTabbedPane in one class, i have also created a seperate class with extends a JPanel. This consists of two textboxs and two buttons. Now i want to add this class as a component to each new tab that i create in the other class.
    However the problem that i have is the reference name that i give for the textboxs and buttons will be the same for the multiple tabs that i create which i guess will not work.
    For example, i create 2 tabs each with one of these instances of this class in each. So therefore there will be two identical buttons with the same reference and two identical textboxes with the same reference.
    This is the code for the class that extends a JPanel: (note: i have cut out all the layout code to simplify the code a little)
    public class client extends javax.swing.JPanel {
        private JButton Sbrowse_btn;
        private JButton Sbrowseto_btn;
        private JLabel SchosenFile_lbl;
        private JLabel SchosenL_lbl;
        private JTextField SchosenLoc_tf;
        private JTextField Schosen_tf;
        private JLabel SsaveTo_lbl;
        private JLabel SuploadTo_lbl;
        private JPanel jPanel2;
        private JPanel jPanel3;
        /** Creates new form client */
        public client() {
            initComponents();
        private void initComponents() {
            jPanel3 = new JPanel();
            SuploadTo_lbl = new JLabel();
            Sbrowse_btn = new JButton();
            SchosenFile_lbl = new JLabel();
            Schosen_tf = new JTextField();
            jPanel2 = new JPanel();
            SsaveTo_lbl = new JLabel();
            Sbrowseto_btn = new JButton();
            SchosenL_lbl = new JLabel();
            SchosenLoc_tf = new JTextField();
    }

  • Use a variable name within a function?

    here's my function....
    myInterval = setInterval (TTMO,15);
    function TTMO () {
    InstanceNameOfMovieClip._x -= (InstanceNameOfMovieClip._x -
    _xmouse)/10;
    InstanceNameOfMovieClip._y -= (InstanceNameOfMovieClip._y -
    _ymouse)/10-2;
    instead of using the "InstanceNameOfMovieClip" can i use a
    variable name? i've tried, but it doesn't work. i also tried using
    the correct hierarchy too, such as this._parent.VariableName
    too.

    you need to concat the linkage to the movieclip using your
    string variable like this
    var mcName_str = "bigBox_mc";
    this[mcName_str]._x = 20;
    you can use this method for looping through incrementally
    named objects
    for(var i:Number=0;i<10;i++)
    this["mc"+i]._x = 20;
    hope that helped

  • Changing variable name

    Hello all,
    I have build a query with a variable fiscal period. I used this variable in input forms in Visual Composer (@fiscal_period) and in BW reports.
    Now end users ask me to change the name of the variable to 'period'. Does this have impact on the existing Visual Composer model?
    Thanks in advance,
    Ralph

    Hi,
    You just change the variable name. After that you need to map again it with input form field as @period, Otherwise it will not get the value. Just map it and deploy it again.
    Thanks
    Chandan

  • Changing feild names within windows.

    I have had a user request to change the name of the Additional Identifier field in IMD to another name. Is this possible, and if so, how?
    Thanks,
    Monica

    Hi,
    Check the following thread :
    Re: Field Name Changes
    Hope this is what you were looking for.
    Regards,
    Jitin
    SAP Business One Forum Team

  • Change layer name within Layer Styles dialog

    Okay, so I'm lame - or maybe it's a fiddly operation to begin with - but half the time I double click a layer name to rename it I get the Layer Styles dialog instead. If the name field can't be made larger and easier to activate, it would be great if I could at least make the name change from within the Layer Styles dialog once I'm in it.
    Other means to make layer renaming simpler would also be apprecated.

    Thanks Michael. Not sure if any of those really simplifies the process though.
    Maybe instead of making a double click to the vast majority of the layer area open the Layer Style they could devote an equal amout of space to the name. Anything in the vacinity of the name (especially immediately above or below it) would activate the name for renamng, and anything reasonably to the left or right of it for Layer Styles. That seems somewhat fair and simpified to me.

  • Change Variable Name

    Hi
    I have a requirement where I want to loop 10 times over an internal table, but passing the same value to all.
    For ex.
    Do 10 times.
    Read table itab into wa index sy-index.
      if sy-subrc = 0.
        var1 = wa-field.
      endif.
    Enddo.
    My requirement is to change this VAR1 to VAR2 in next iteration, then to VAR3.......upto VAR10 for every iteration of loop.
    Regards
    Kapil

    try this .
    declare variable VAR1 to VAR 10 .
    DATA:  LV_FIELDNAME(9)   TYPE C,
           LV_PREFIX(3)      TYPE C VALUE 'VAR'
           LV_LINE_NUMBER(2) TYPE N .
    FIELD-SYMBOLS : <FS_GLOBAL_VARIABLE>.
    Do 10 times.
      ADD 1 TO LV_LINE_NUMBER.
      CONCATENATE LV_PREFIX
                  LV_LINE_NUMBER
             INTO LV_FIELDNAME.
      ASSIGN (LV_FIELDNAME) TO <FS_GLOBAL_VARIABLE>.
      Read table itab into wa index sy-index.
       if sy-subrc = 0.
         <FS_GLOBAL_VARIABLE> = wa-field.
       ENDIF.
    ENDDO
    Jitendra

  • Changing variable name breaks serialization

    I have a class like so
    class aClass {
        private static final long serialVersionUID = 1; 
        private ArrayList list = new ArrayList();
        private void readObject(ObjectInputStream in)throws IOException, ClassNotFoundException {
         in.defaultReadObject();
            this.list = new ArrayList(this.list);     //defensive copy
    }The problem is i renamed 'list' to 'newList'. Now the deserialization fails. Is there any way around this? Its still a list and everything is the same but the name. I thought serialization used the positions of variables not their names? And I also thought since I had my UID the same it would just load it without complaint?
    I have a bunch of files created with this in them, and I need a tip on how to convert them. thanks!

    easy peasy
    class aClass {
        private static final long serialVersionUID = 1; 
        private ArrayList list = new ArrayList();
        private void readObject(ObjectInputStream in)throws IOException, ClassNotFoundException {
         this.list = (ArrayList) in.readObject();  //<---new
            this.list = new ArrayList(this.list);     //defensive copy

  • Dynamic creating field names within Loop

    Hi,
    I've a record which comprises of a few key fields and then 52 qty fields, one for each week of the year. ( Not my design honest!!).
    Anyway with in a Cursor there are currently 52 "IF" statements clearing out values less than the current week number. I'd tried to replace this with the following. However I'm having trouble with the " 'c1_rec.qty'&#0124; &#0124;lv_count " bit.
    Has anyone got any ideas?
    lv_week:=22; ( added for clarity )
    lv_count:=1;
    WHILE lv_count < lv_week LOOP
    'c1_rec.qty'&#0124; &#0124;lv_count :=0;
    lv_count:=lv_count+1;
    END LOOP;
    John-Paul Thompson

    John-Paul;
    If I understand the question correctly, you have a table with 52 columns, one for each week of the year. You are trying to zero the quantity for each week prior to the current week. I'm going to take a sab at this. Bear in mind that I have no way to debug the code.
    DECLARE
    c NUMBER;
    n NUMBER;
    v_sql VARCHAR2(2000)
    lv_week NUMBER:=22; ( initialize week#)
    lv_count NUMBER:=1;
    BEGIN
    v_sql := 'UPDATE c1_rec SET '
    WHILE lv_count < lv_week LOOP
    v_sql := v_sql&#0124; &#0124;
    'qty'| |TO_CHAR(lv_count) &#0124; &#0124;' :=0';
    lv_count:=lv_count+1;
    IF lv_count < lv_week THEN
    v_sql := v_sql &#0124; &#0124; ', ';
    END IF;
    END LOOP;
    --sql := v_sql &#0124; &#0124; YOUR WHERE CLAUSE
    c:= dbms_sql.open_cursor;
    dbms_sql.parse(c, v_sql, dbms_sql.native)
    n:= dbms_sql.execute(c);
    dbms_sql.close_cursor(c);
    END;
    HTH
    Randall
    null

  • How to change dinamically variable name?

    Is it possible to change variable name dinamically into loop?
    loop at itab.
    move itab-item to field_x.
    endloop.
    I would copy my itab-item into field_1, field_2......field_x at each loop.
    Thanks
    Alfonso.

    You have to use the field symbol for the field giornoX not for the structure
    DATA: BEGIN OF wa_alv OCCURS 0,
            pernr            LIKE pa0001-pernr,
            persk            LIKE pa0001-persk,
            des_grado_abbrev LIKE zhr_descr_grado-des_grado_abbrev,
            vorna            LIKE pa0002-vorna,
            nachn            LIKE pa0002-nachn,
            giorno1          TYPE char12,
            giorno2          TYPE char12,
            giorno3          TYPE char12,
            giorno4          TYPE char12,
            giorno5          TYPE char12,
            giorno6          TYPE char12,
            giorno7          TYPE char12,
          END OF wa_alv.
    data tb_alv like table of wa_alv.
    field-symbols: <giorno> type any.
    data: name_giorno(13).
    LOOP AT tb_alv ASSIGNING wa_alv
      LOOP AT tb_orario.
       do 7 times.
        concatenate 'wa_alv-giorno'  sy-index into name_giorno.
         assign (name_giorno) to <giorno>.
         giorno  = tb_orario-orario.
        enddo.
        ENDLOOP.
    ENDLOOP.
    bye
    enzo

  • How to use an array for variable name of swing components using NetBeans

    I'm completely new to Java and GUIs, so excuse me if I use the wrong terminology. I'm making a JFrameFrom in NetBeans. I'm getting really tired of typing instructions like jTextField15.setText(variable[15].text); I would like to make the variable names of my text fields an array so I can use a loop to change the values, text, tooltips, etc. When I click "change variable name" it won't let me put an array in. The code that Swing generates is protected and I can't change it. I know there must be a way to do this. Any help is appreciated.

    Try not to use the NetBeans visual GUI builder. Then it should be easy to create an array of text fields:
    JTextField[] tfs = new JTextField[15];
    for (int i = 0; i < tfs.length; i++) {
        tfs[i] = new JTextField(10);
    }For laying out the text fields, see: [http://download.oracle.com/javase/tutorial/uiswing/layout/using.html]

  • Variable scope within an interface and some questions

    I am creating a DataStorage interface with a member variable (can I call it a member variable when it is in an interface?) called dataObject. From what I remember, and what the compiler is telling me, the scope declarations "private," or "protected" can not be used on either methods or member variables in an interface.
    Now I have another class DataInput that implements DataStorage and I want to make the dataObject private and put in accessor methods to get to the dataObject. But I also remember reading something that said, during inheritance you can not make the scope of the method (and variable?) more narrow. Meaning if a method was defined as default in the parent class, the subclass can not override that method to give it private access all of a sudden.
    Now a couple of questions with this...does that rule only apply to subclassing (that is with extends) or does it also apply to implementing interfaces. Second question, I am pretty sure that rule applies to methods that are being overriden, but does it also apply to variables in an interface...because if that is the case, I can't re-declare the variable in the class that implements the interface to be private...and then there is no way to protect that variable.
    By the way I did re-declare the variable in the subclass (implementing class) and declared it as a private, and it works...but I'm still trying to figure out the general rule.

    well if the interface variables are implicitly public static final, how come I am able to re-declare the variable name within the class that implemented the interface.
    If for example in interface Car there is a variable color, how come in class Honda implements Car, I can redeclare the variable color, and give it public access. I thought final meant final, no redeclaring...but does that not hold for static variables?

  • Change button name in a for-loop

    Hi all,
    I would like to implement a 'for loop' to add buttons to my panel depending on the value of max_number.
    The postion of these buttons will also change with each passing of the loop.
    The code below implements this. But when I click the buttons they only return the action listener of the last button drawn. This is because the JButton my_button is reused in each pass through the loop.
    What I need is to change the name of the button on each passing of the loop so that I create a new button each time with it's own unique action listener.
    Is there a way of adding/appending the value of 'i' to the button name each time the for loop is run?
    For example
    When i = 0 -> JButton my_button0 = ...
    When i = 1 -> JButton my_button1 = ...
    etc, etc,
    for (i = 0; i < max_number; i++)
    JButton my_button = new JButton(Integer.toString(i));
    my_button.addActionListener( new ActionListener()
    { public void actionPerformed(ActionEvent event)
    { do something depending on the value of 'i' }});
    addComponent(my_button, (2*i+1) , 4 , 1 , 1); //add newly created button to position x = (2*i+1), y = 4
    } //end for

    What?! Are you talking about the variable name? You can't, shouldn't, needn't use different variable names in a for loop, since the variables "expire" each time the loop is run. For instance:
    for(int i = 0; i < 10; i++) {
       //j doesn't exists even if this loop is on its 10'th lap!
       int j = i;
    }And you will have a problem with the ActionListener as well, since it depends on the "i" variable. "i" can't be accessed from an anonymous class unless it has been declared final, in which case it won't work for you.
    So: the my_button variable will contain a new JButton each time!
    Nille

  • I need to change the name of Schema in the Insert command by using variable

    Hi
    I need to write a code to populate 450 schemas having same table names and also specify the columns needed to be inserted. for that i am trying to make the Schema Name a variable and put the whole statement in a loop to change the name of the Schema. its not working can any one guide me in this..Thae sample of my insert statement is
    INSERT INTO A01.tablename
    In this the "A" is constant and 01 is being changed to 02...450..
    Thanks

    Not sure to completely understand your need, but assuming that column names and values to be inserted are the same for all schemas, here a short example :
    SQL> desc a001.test
    Name                                      Null?    Type
    A                                                  NUMBER
    B                                                  VARCHAR2(10)
    SQL> desc a002.test
    Name                                      Null?    Type
    A                                                  NUMBER
    B                                                  VARCHAR2(10)
    SQL> desc a003.test
    Name                                      Null?    Type
    A                                                  NUMBER
    B                                                  VARCHAR2(10)
    SQL> declare
      2     i       number;
      3     str     varchar2(100);
      4  begin
      5     for i in 1..3 loop
      6             str := 'insert into a'||lpad(i,3,'0')||'.test(a,b) values(1,'||chr(39)||'ABC'||chr(39)||')';
      7             execute immediate (str);
      8     end loop;
      9     commit;
    10* end;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL> select * from a001.test;
             A B
             1 ABC
    SQL> select * from a002.test;
             A B
             1 ABC
    SQL> select * from a003.test;
             A B
             1 ABC
    SQL>                                                                          

Maybe you are looking for

  • Oracle VPD on Remote database using DBLINk

    Hi All, How can i apply row level security on a table that is available in another database using DBlink we have two databases PDSSM and EVTA, and i would like to apply row level security on a table in EVTA from a schema in PDSSM using dblink. MXODSA

  • PL/SQL Performance problem

    I am facing a performance problem with my current application (PL/SQL packaged procedure) My application takes data from 4 temporary tables, does a lot of validation and puts them into permanent tables.(updates if present else inserts) One of the tem

  • Critical Issue - 500- Internal Server Error for request in User's Inbox

    Hi, We have developed and deployed SOA composite and custom task flow (For Customized Email notifications).[30.7.1.1 Creating a Task Flow with a Router - http://docs.oracle.com/cd/E23943_01/dev.1111/e10224/bp_designtf.htm#SOASE744] When a request is

  • Colorprofil for 24 imac here

    Hi there, this is for us with the uneven brightness/color issue of the imac screen. I did a profil with coloreyes soft/spider hardware. Gamma L* D65 Very Important: Set yout imac to the brightest Level! The profile dimms the brightness down to 200cd

  • How to create a project structure with the Business Bluprint transaction S

    Hi How to create a project structure and add the required scenarios for your SAP system to your project structure with the Business Bluprint transaction SOLAR01. Also how to add your SAP system configuration structures to your project structure with