Creating a variable whose name is the value of a String

Hi guys
i want to create java variables dynamically whose name is the
value of String .
Such as
String str="object";
now i want to ceate a variable of
type int whose name will be "object".
in what manner i can do this.

i want to create java variables dynamically whose
name is the
value of String .
Such as
String str="object";
now i want to ceate a variable of
type int whose name will be "object".
in what manner i can do this.
You can't. The best you can do is create a Java source file and compile it on the fly.
Could you tell us why you want to do this? I have no doubt at all that you are working with a bad design, and maybe we could help you fix it.

Similar Messages

  • Is there a way to reference a variable name by the value of a String?

    I realize my title may not be expressing the question accurately so...
    In perl I can do this:
    $varname = "nIterations";
    ${$varname} = 27;
    which is the same thing as
    $nIterations = 27;
    Is there a way to do this in Java?
    eg I want something like
    String varname = new String( "nIterations" );
    How can I refer to a variable programmatically from the value of the varname string, or is there not a way to do this?
    Thanks!
    -Andy

    Thank you, I'm very new to java and am not sure I am seeing the big picture. I searched the forums and found this example:
    Map textFieldMap = new HashMap();
    textFieldMap.put("1", new JTextField());
    textFieldMap.put("2", new JTextField());
    JTextField textField = (JTextField)textFieldMap.get("1");
    textField.setText("some value"); // text field associated with "1"
    What I am confused with is how those textfields correspond to the 48+ textfields I have already placed on my applet canvas. I understand the example above as far as using the map to access specific textfields, but I am not sure how those textfields will match up to the ones I have ( which are named right now S11 , S12, ..., S116, ..., S31, S32, .., S316
    I am sure I am missing something.
    Thank you
    -Andy

  • How to create web interface whose name includes _ (underscore)

    Hi Experts,
    In my project we are creating web interface. The steps are as below:
    1) Run transaction code upspm and copy the planning folder
    2) Save the planning folder as web enabled planning folder
    3) Generate web interface for step 2. Here I have to provide following details:
    Name of planning folder
    Web Application
    Package
    I have to create Web Application whose name should include _ like ztest_test
    The system is not allowing me to create web application whose name includes _
    Can you please how I can create web application whose name includes _
    I am not allowed to use the wizard or manual method to create web interface.
    Regards,

    Hi
    U can use the transaction BPS_WB to create u r web interface builder and for execute check another transaction BPS_wef (check once).
    UPSPM for planning folder not for web interface builder.
    Thanks,
    Debasish

  • Is it possible to create a variable in bex with the last work day?

    Hi Gurus
    Is it possible to create a variable in bex with the last work day?
    Actually end-user every day open queries,
        - Put in selection date day - 1 or
        - put last Friday if the day is Monday or
        - put last Thursday if the day is Monday and Friday is holiday (in a calendar for example 25 the December).
    Please do the needful. It is urgent
    Thanks in advance
    Raj

    Try this logic in a customer exit:
    DATA:  l_s_range TYPE rsr_s_rangesid.
    DATA:  X_PERIOD LIKE T009B-POPER,
               X_YEAR   LIKE T009B-BDATJ.
      CASE I_VNAM.
      WHEN 'ZPREVWORKDAY'.
        DATA: l_DayOfWeek(1) TYPE C,
              l_act_date     TYPE d,
              l_prev_date    TYPE d.
        l_act_date = sy-datum.
        CALL FUNCTION  'DATE_COMPUTE_DAY'
             EXPORTING DATE = l_act_date
             IMPORTING DAY  = l_DayOfWeek.
        CASE l_DayOfWeek.
          WHEN '1'.
            l_prev_date = l_act_date - 3.
          WHEN '2'.
            l_prev_date = l_act_date - 1.
          WHEN '3'.
            l_prev_date = l_act_date - 1.
          WHEN '4'.
            l_prev_date = l_act_date - 1.
          WHEN '5'.
            l_prev_date = l_act_date - 1.
          WHEN '6'.
            l_prev_date = l_act_date - 1.
          WHEN '7'.
            l_prev_date = l_act_date - 2.
        ENDCASE.
        l_s_range-low  = l_prev_date.
        APPEND l_s_range TO e_t_range.
    ENDCASE.
    Edited by: Tyler Blouse on Feb 13, 2008 8:28 PM

  • Data type of the value in a string

    is it possible to determine what is the data type of the value of my string? for example if the user enters an integer, how do i know its an integer?

    if what the user entered is either 1 character,more than
    1 characters(a string), a whole number with no
    decimail places(an int) or a number with decimal
    places(a double).Those aren't mutually exclusive possibilities. If the user enters12345is that supposed to be a string with 5 characters or a whole number?
    how do i do that before i actually
    come to the Integer.parseInt or double.parsedouble
    statement?You don't. You use those statements to determine whether the string input can be interpreted as an integer or as a double.

  • Is it possible to use the value of a string to reference a component in the

    I'm fairly new to Java so this may be a stupid question!
    Is it possible to use the value of a string to reference a component in the code? For example in the code below, Wall is a class holding 3 different arrays. The Robot class has an array called finishBricks. When the buildWall method is run it receives the integers width and height which are used to construct the dimensions string. I want to use this string to then load the appropriate Wall array into the finishBricks array.
    I hope this makes sense! Any help would be greatly appreciated!
    class Robot {
    public double[][] finishBricks;
    public void buildWall(int width, int height) {
    Wall w = new Wall();
    String dimensions = "Wall" width "x" +height;
    this.finishBricks = w.xxxx; // where xxxx is replaced by whatever the String dimensions is
    class Wall {
         public double[][] Wall4x2 = {
              {-30.00,-01.60,27.45},
              {-30.00,-06.75,27.45},
              {-30.00,-13.55,27.45},
              {-30.00,-20.35,27.45},
              {-30.00,-22.00,28.65},
              {-30.00,-16.85,28.65},
              {-30.00,-10.05,28.65},
              {-30.00,-03.25,28.65}
         public double[][] Wall3x3 = {
              {-30.00,-01.60,27.45},
              {-30.00,-06.75,27.45},
              {-30.00,-13.55,27.45},
              {-30.00,-15.20,28.65},
              {-30.00,-10.05,28.65},
              {-30.00,-03.25,28.65},
              {-30.00,-01.60,29.85},
              {-30.00,-06.75,29.85},
              {-30.00,-13.55,29.85},
         public double[][] Wall2x4 = {
              {-30.00,-01.60,27.45},
              {-30.00,-06.75,27.45},
              {-30.00,-08.40,28.65},
              {-30.00,-03.25,28.65},
              {-30.00,-01.60,29.85},
              {-30.00,-06.75,29.85},
              {-30.00,-08.40,31.05},
              {-30.00,-03.25,31.05},

    Map walls = new HashMap ();
    walls.put ("2x2", new double[][] {
        new double[] {
            1,
            0
        new double[] {
            0,
            1
    double[][] wall = (double[][]) walls.get ("2x2");

  • How to avoid creating a variable to store a temporary value

    This is an artificial example, but it best illustrates what I am trying to do:
    I could create a local variable whose scope doesn't extend beyond the step, but I'd like to avoid that local variable clutter. Or I could dynamically create and delete properties in post expressions, but that would lead to variable names that are invalid at edit-time.  Or I could create a custom Sequence Call step type with a custom subproperty to hold the temporary value, but that is not a very generic solution.
    But really, I'd like to just have two expressions I could use in the sequence Parameter and the Custom Condition that somehow each point to the other, to keep the rest of the step configuration as clean as possible (although the two expressions I am seeking may end up being more complex than the alternatives).  Is this possible?  I think it may be, but I can't figure it out.  One of the alternative solutions wouldn't kill me, but the solution I have in mind would be nicer!

    What you have seems to be the most clear solution to this.  For the dynamic case, if you are worried about errors, you may want to use #NoValidation.  Here's a paragraph from the linked document about using #NoValidation.
    http://zone.ni.com/reference/en-XX/help/370052K-01/tshelp/infotopics/2012whatsnew/
    You can now use the #NoValidation directive in an expression to disable evaluation error checking for part or all of the expression. Use this directive to suppress errors reported at edit time that will not occur at run time, such as using a variable the sequence creates at run time by using the TestStand API. Use this directive without a parameter list to suppress error checking for the remainder of the expression or pass a separate expression as the parameter to this directive to suppress error checking for only the parameter expression.
    Jesse S.
    Applications Engineer
    National Instruments

  • Variable table name in the select statment ?

    data: h_itab like hier_out occurs 0 with header line,
          table_name(30) type C.
    here i declare h_itab as the variable for the table name
    itab_name = input_name
    input_name is imported
    select * from table_name
           into table h_itab
           where OBJVERS = 'A'.
    it does not allow me to use table_name in the select statement i get the error 'table_name is not defined i the abap dictionary as a table, projection view or database view'.
    Any suggestions are highly appreciated.
    Thanks in advance,
    BWer

    Hi,
    You must enclose the name of the table in braces to let the compiler know that the value will be supplied at run time.
    For example -
    tables mara.
    data table_name(30) type c.
    table_name = 'MARA'.
    SELECT *
      FROM (table_name)
    endselect.
    Regards,
    Anand Mandalika.

  • How to create a dropdown list to list the values from two different tables?

    Hi,
    I have the following requirement:
    1. I have to create a dropdown list to display all the values from the second column of  a table.
    2. Another dropdown list to display all the values from the second column of another table.
    3. A text box should help me to add the selected values.
    How to get this done in a PDF? Please help.
    Regards,
    Latha

    Is this a LC form? Because Acrobat forms have no concept of tables, just
    individual fields...

  • HT3231 I ended up having to create a new user name because the migration assistant wouldn't let me put the data back onto my original user name.  I now have to log into the new user name to see all my data, apps, photographs etc. What went wrong?

    I have a Mac that was part of the recall involved with the faulty Seagate hard drives.  The folks at the Apple Store near me changed the hard drive early December, 2012. I had my data, etc. all backed up on a portable hard drive.  When the Mac was returned with the new hard drive, I used the Migration Assistant to bring everything back over. Trouble was, it wouldn't let me bring it over to my original user name.  I was forced to create a new user name that became the place where everything was restored.  I can't see any data on my old user name, just the basics.  Everything is on the new user name but I wish I didn't have it (just want everything back the way it was originally).  Any suggestions?

    Probably the cleanest thing to do is to erase and freshly install the operating system on the new drive. Then, on the first boot up, don't create a new user, instead select the option in Setup Assistant to immediately bring things over from your backup, which you must connect via USB or firewire. Setup Assistant will then recretae your old user to look just like it used to.
    Before doing this, make sure you realize you will lose everything on the new drive by erasing it, and make sure your backup is still viable.

  • Populate variable 2 according to the value selected in variable 1

    Hello BW Experts,
    I have two variables sales area vsarea and sales org vsorg.
    eg: data:
    sales area area1 contains
        1) sales org org1
        2) org2
    sales area area2 contains
        1) org3
        2) org4
    req:
    first the user selects the values in the vsarea area1. then when he comes to select the variable vsorg it should show only show org1, org2. it should not show org3 and org4.
    possible solutions:
    -- 1) is this possible using the variable exit ?
    please suggest any solutions for the above problem.
    Thanks,
    BWer

    thanks for the suggestion.
    however what I wanted to do is somewhat different.
    variable selection sequence:
    sales area then sales org
    1) variable 1: sales area: user selects 1000 for sales area
    2) variable 2: sales org: I should only show 1001, 1002, 1003 sales org, which belong to 1000 sales area
    please suggest if there is already a solution for this.
    Thanks,
    BWer

  • T.code F110 Created a proposal, could I modify the value date?

    Hi All,
    I need to create a proposal with tha value date successive to posting date....
    In particular, i wonder if, before running the payment i can modify the "value date" of the scheduled proposal  by hand.
    Thanks...
    Gandalf

    Hi Umberto,
    My understanding of your requirement is like this: When you make a payment to a vendor, it will be credited in his bank account say 2 days after the payment is generated in your system. Say if you have generated a payment document on 24th March, it will be credited to the vendor account on 26 th march. and you want to maintain the value date as 26th march in your payment document.
    If this is the requirement, maintain value date in FBZP settings, under bank determination, for the payment method/hosue bank and HB ID combination. You have to mention number of days to value date.
    Please let me know if this is your requirement

  • Field name and table name for the value field

    hi,
        i requred the  value field  for  which the quantity that is not delivered in purchase order, so please tell  me which field i have to go for the value field.
    thanks and regards.

    Hi,
    There is no direct field to get the PO Open qty(undelivered Qty).
    Take the PO quantity for each Item from EKPO-MENGE.
    For each PO Item there will be multiple GR(good's receipts) 's in MSEG table.
    So pass EBELN and EBELP for MSEG table and Take all the GR Quantities(ERFMG) field and sum up .(have to take care of the Movement type also, becasue there will be some returns and GI's).
    Substract the GR qty from PO qty you will get the UNDELIVERED QTY of A PO.
    Regards,
    Anji

  • Load a class based on the value of a string

    I have a string coming in into a servlet.
    I want to instaniate a class that is the same name
    as the string.
    A class exists for every possible value of the string.
    this is what my vision is.
    public ActionForward execute(
         ActionMapping mapping,
         ActionForm form,
         HttpServletRequest request,
         HttpServletResponse response)
         throws Exception {
         SubmitForm frm = (SubmitList)form;
         String classname = (String)request.getAttribute("listToEdit");
         //this is where the help is needed.
            //create an instance of the correct object.
            //pass it the form
            //class that objects execute method
         obj o = loadclass(classname);
            obj.setForm(frm);
            obj.execute();

    thanks steve , class.Forname is what i was looking for.
    I realized i need to cast it to the appropriate object and i was looking into that. You just solved it with the interface example.
    One more question.
    does my class have to implement the interface i create.
    public class TelephonNumbers implements ListEditInterface {
           private ActionForm form;
           public void setForm(ActionForm form) {
           this.form = form;}      
           public void execute(HttpServletRequest r) {
                  //get session bean
                  //update appropriate list in bean
                  //put the bean back into the request/session
                  //pass control back to action class.
    }

  • How to change the value of subtitution string in a page at runtime

    Hi,
    I need to change the value of a substitution string which is mentioned in application attributes at runtime.
    The value will be fetched from a field in database on load of each screen.
    Can anybody help.......
    Help will be appriciated........thanx in advance
    Sunil

    Substitution strings are meant to be static, like global constants.
    If you need some variable stuff, use application level items and set them using Application level computations/processes

Maybe you are looking for

  • SOLUTION: Chapters of more than one movie usable on a single DVD (w. iDVD)

    If you want to put more than one movie with chapters made in iMovie onto a single DVD using iDVD--and have the chapters of all movies usable--do this: in iDVD, simultaneously drag the icons for all the movies you want to use into the background of th

  • Need help identifying internal parts on pavilion dv9930 laptop

    Need to know and get pictures of internal parts and indentfy what im missing next to the memory on a hp pavilion laptop model dv9930 looks like missing some type watch battery also something with 3 wires tha are numbered on a computer that was given

  • Unable to purchase/download apps to new iphone 5c

    Since I bought my iphone 5c, I have not been able to purchase any new apps, tones or music.  I will click on 'buy' and I'm prompted for my password, I enter password and nothing happens.  I have logged out and back into to apple ID and have restarted

  • No playback in PP CS5.0.3, worked fine several weeks ago...

    I am unable to get a timeline to playback in PP CS5.0.3 with either existing or new projects (Win 7) on any source video, whether out of my Canon 5D2, Sony CX550, or simple AVI. The last time I used PP was several weeks ago and it was working fine th

  • Is JTA part of JDK

    Can any one tell me if JTA is part of JDK/JRE. That is, if I have JDK/JRE is there any need for me to have it separately