Getting Input - INT Variable for number or array element? Arggh.

This is what I have. It is not working. Any ideas?
package ArrayPackage;
* @author  Terry
import java.io.*;
public class NumArray {
    int num1=1;
    int num2=0;
    int elements=0;
    int[] numArray = new int[elements];
    void insertNumbers(){
        for (int i =0; i < numArray.length;i++){ 
            numArray[i] = ((i % 2) == 0) ? num1 : num2;
    void printNumbers(){
        for(int i=0;i<numArray.length;i++){
            System.out.println("Element "+(i+1)+": " + numArray);
public static void main(String[] args) {
NumArray ezPrintsArray = new NumArray();
System.out.println("elements? ");
try{
ezPrintsArray.elements = System.in.read();
catch(IOException e){
ezPrintsArray.insertNumbers();
ezPrintsArray.printNumbers();

Here is what I have. At this point you are right. Basically it is not updating the elements variable. So at this point it runs, but it runs only 5 times. It is not updating the elements variable, and I have tried using this.elements, but that does not work. Help.
* NumArray.java
* Created on May 21, 2004, 10:22 AM
package ArrayPackage;
* @author  Terry
import java.io.*;
public class NumArray {
    int num1=1;
    int num2=0;
    int elements=5;
    int[] numArray = new int[elements];
    void getElements(){
       System.out.println("elements? ");
        try{
        elements = System.in.read();
        catch(IOException e){
    void insertNumbers(){
        for (int i =0; i < numArray.length;i++){ 
            numArray[i] = ((i % 2) == 0) ? num1 : num2;
    void printNumbers(){
        for(int i=0;i<numArray.length;i++){
            System.out.println("Element "+(i+1)+": " + numArray);
public static void main(String[] args) {
NumArray ezPrintsArray = new NumArray();
ezPrintsArray.getElements();
ezPrintsArray.insertNumbers();
ezPrintsArray.printNumbers();

Similar Messages

  • How to convert an int variable into Number

    Hi all,
    I am using Jdeveloper 11.1.1.2
    When I insert a row in a entity object I want to create another row in another entity object, but when I am setting the attribute for the new row I have a problem.
    Here is the code:
    int a = EO1Impl.paramA;
    NameEO2Impl.setAttribute("Attribute1", a);
    The error is that variable a is an int, while Attribute1 is a Number.
    How can convert an int to a Number.
    Thank you.

    Andrea9,
    If a, as you say is an int, and assuming you mean an oracle.jbo.domain.Number,
    NameEO2Impl.setAttribute("Attribute1", new oracle.jbo.domain.Number(a));works just fine.
    John

  • Setarraybo​unds to modify array get error-1732​5,wrong number of array indices

    hello:
       i tried to use setarraybounds(Locals.Raw_values,"[1]","[6][0][0]"​) to set new bounds value of original array[1][1200]
    but get error: -17325,wrong number of array indices
    and use setarraybounds(Locals.Raw_values,"[0][0][1]","[6][​0][0]") gets error-17324,array index out of bounds
    what can i do?

    now i know i should use "[600]", thanks

  • Unlimited number of array elements, help please!

    Hi everyone,
    I have written this code for comparing two arrays but i don't know how to accept all types array lengths. Now i am limited to 5 elements and i want it to accept the the users desired number of elements. How should i do?
    import java.util.*;
    class console
    public static void main (String[] args)
    ConsoleInput ci = new ConsoleInput();
              System.out.print("Hur m�nga Vektorer ska lagras? ");
              int antal = ci.readInt();
              if (antal<2)
             System.out.println("Du beh�ver 2 st vektorer");
             System.out.println("Hur m�nga element per vektor?");
             int antalelement = ci.readInt();
              System.out.println();
                   for (int j=0 ; j<antal-1; j++)
                   System.out.print("Ange vektor1: ");
                   int vektor = ci.readInt();
                   int vektor3 = ci.readInt();
                   int vektor2 = ci.readInt();
                   int vektor4 = ci.readInt();
                   int vektor5 = ci.readInt();
                   int[] vektor1 = new int[] {vektor,vektor3, vektor2, vektor4, vektor5};
                  int langd = vektor1.length;
                  System.out.print("Ange vektor2: ");
                   int element1 = ci.readInt();
                   int element2 = ci.readInt();
                   int element3 = ci.readInt();
                   int element4 = ci.readInt();
                   int element5 = ci.readInt();
                   int[] vektor21 = new int[] {element1,element2,element3, element4, element5};
                   Arrays.sort (vektor21);
                    int  kopiera = vektor1.length + vektor21.length;
                             int[] nyvektor = new int [kopiera];
                              for(int i = 0; i < vektor1.length; i++)
                                   nyvektor[i] = vektor1;
                             for(int i = 0; i < vektor21.length; i++)
                                  nyvektor[vektor1.length + i] = vektor21[i];
              System.out.print("Unionen ar: ");
                                  verktyg.sort(nyvektor);
                                  int counter = 0;
                                  for(int k = 1; k < nyvektor.length; k++)
                                  if(nyvektor[k] == nyvektor[k-1])
                                  counter++;
                                  int[] union = new int[nyvektor.length - counter];
                                  union[0] = nyvektor[0];
                                  int b = 1;
                                  for(int k = 1; k < nyvektor.length; k++)
                                  if(nyvektor[k] != nyvektor[k-1])
                                                           union[b] = nyvektor[k];
                                                           b++;
                                                           for (int h = 0; h<union.length; h++)
                                                           System.out.print(" " +union[h]);
    System.out.println();
    System.out.print("Intersection ar: ");
    Arrays.sort(nyvektor);
                   int counter1= 0;
              for(int i = 1; i < nyvektor.length; i++)
              if(nyvektor[i] == nyvektor[i-1])
              counter1++;
                   int[] intersection = new int[counter1];
              //c[0] = C[0];
              int a = 0;
              for(int i = 1; i < nyvektor.length; i++)
              if(nyvektor[i] == nyvektor[i-1])
                                       intersection[a] = nyvektor[i];
                                       a++;
                        for(int i=0; i<intersection.length; i++)
                                       System.out.print(" " +intersection[i]);
    System.out.println();
    System.out.println("Differensen ar: ");
    Arrays.sort(nyvektor);
         int counter2 = 0;
                        for(int i = 1; i < nyvektor.length; i++)
                        if(nyvektor[i] == nyvektor[i-1])
                        counter2++;
                             int[] difference = new int[vektor1.length-counter];
                                                 boolean falsk = false;
                                                 int k=0;
                                                 for(int i = 0; i < vektor1.length; i++)
                                                      for(int d=0; d<vektor21.length; d++)
                                                                if(vektor1[i]!=vektor21[d])
                                                                     falsk = true;
                                                                else
                                                                     falsk = false;
                                                                     break;
                                                                if(falsk)
                                                                     difference[k] = vektor1[i];
                                                                     k++;
                                            for(int i=0; i<difference.length; i++)
                                  System.out.print(difference[i] + " ");

    How about this?import java.util.*;
    import java.io.*;
    class DynamicVectors
      public static void main (String[] args)
        BufferedReader console
          = new BufferedReader (new InputStreamReader (System.in));
        String consoleLine = "";
        StringTokenizer tokenizer;
        System.out.print ("Hur m�nga Vektorer ska lagras? ");
        try
          consoleLine = console.readLine();
        catch (IOException ioe)
          System.out.println (ioe);
        tokenizer = new StringTokenizer (consoleLine);
        int antal = Integer.parseInt (tokenizer.nextToken());
        if (antal<2)
          System.out.println("Du beh�ver 2 st vektorer");
        for (int j=0 ; j<antal-1; j++)
          int vektorSize;
          System.out.print("Ange vektor1: ");
          try
            consoleLine = console.readLine();
          catch (IOException ioe)
            System.out.println (ioe);
          // Here's where the fun starts...
          tokenizer = new StringTokenizer (consoleLine);
          vektorSize = tokenizer.countTokens();
          int[] vektor1 = new int [vektorSize];
          for (int i = 0; i < vektor1.length; ++i)
            vektor1 = Integer.parseInt (tokenizer.nextToken());
    // ...and that's all there is to it.
    int langd = vektor1.length;
    System.out.print("Ange vektor2: ");
    try
    consoleLine = console.readLine();
    catch (IOException ioe)
    System.out.println (ioe);
    // Here's where the fun starts...
    tokenizer = new StringTokenizer (consoleLine);
    vektorSize = tokenizer.countTokens();
    int[] vektor21 = new int [vektorSize];
    for (int i = 0; i < vektor21.length; ++i)
    vektor21 [i] = Integer.parseInt (tokenizer.nextToken());
    Arrays.sort (vektor21);

  • How to get input from keyboard scanner into an array

    This is probably a very basic question but I'm very new to java..
    My task is to reverse a string of five digits which have been entered using keyboard scanner.
    E.g. - Entered number - 45896
    Output - 69854
    I used the StringBuffer(inputString).reverse() command for this, but i need a more basic method to do this.
    I thought of defining an array of 5
    int[] array = new int [5];
    and then using,
    Scanner scan = new Scanner(System.in);
    to enter the numbers. But I can't figure out how to get the five input numbers into the array.
    If I can do this I can print the array in reverse order to get my result.
    Any other simple method is also welcome.

    Hey thanks for the quick reply,
    But how can I assign the whole five digit number into the array at once without asking to enter numbers separately?
    E.g. - if entered number is 65789
    Assign digits into positions,
    anArray [0] = 6;
    anArray [1] = 5;
    anArray [2] = 7;
    anArray [3] = 8;
    anArray [4] = 9;
    I'm really sorry but I am very new to the whole subject.

  • Input a variable for the time shift 'TIME=NEXT(var)'

    Hi experts,
                Is there any way to make the parameter on the time shift 'TIME=NEXT(%var%)'
    the idea is the user would input/send the value that will be place on the NEXT parameter..
    I've tried using the get statement but it doesn't retrieve the values.,..
    *REC(ACCOUNT="ACCT1",TIME=NEXT(GET(ACCOUNT="ACCT2")))
    it doesn't work..   i also tried the lookup.. it also doesnt work...
    Thanks,
    BennieJay

    Hi again nilanjan chatterjee,
            The process that we want to achieve is we want to make a sort of scheduling for the transactions.
    where the date of the lenght of the transaction is to be inputted in months. and for that we need to make use of the time shift NEXT. but the length should be variable because it is inputted.
    Thanks.
    Bennie Jay

  • Text variables for non-input ready variables

    I have a query with a structure in the Rows section.  The row structure contains three selections for different time periods.  Two of the time periods are based on non-input ready variables for Calendar Month.  The user will enter a calendar month and the other two selections will be based on the month that was inputted.  Since the time periods are dynamic, I need the text in the rows to reflect the appropriate Cal. Month value.  I have tried using a customer exit to define text variables but they are not working.  My text variables are called "CMON_TXT_D01" and "CMON_TXT_D02".  If the user selects 'Dec. 2010', the report would look like this
    Dec. 2010  => user inputs this value
    &CMON_TXT_D01&  => customer exit calculates -1 month back from inputted value
    &CMON_TXT_D01&  => customer exit calculates -2 month back from inputted value
    I need it to look like this if the inputted value was 'Dec. 2010'
    Dec. 2010
    Nov. 2010
    Oct. 2010
    I can get the text variable based on the input-ready variable to work but the two selections that are based on the non-input ready variables are not working.  Does anyone know how to get the text variables to work for the non-inpjut ready variables?
    Thanks.

    Hi,
    I would do it this way;
    1) Create a Row Structure
    2) Create Row Selection for Dec 2010 by restricting Cal. Mth. by the User Input Var
    3) Create Row Selection for Nov 2010 by restricting Cal. Mth. by the User Input Var with a Var Offset of -1
    4) Create Row Selection for Oct 2010 by restricting Cal. Mth. by the User Input Var with a Var Offset of -2
    5) Create a Text Var whose processing is by Replacement Path & choose Variable with the User Input Var under Replacement Path options
    6) Edit the Description of each of the 3 Row Selections to contain the Text Var in (5)
    7) The Text Var should automatically reflect the User Input selection & the offsets defined on the same in the Row Selection Captions
    --Priya

  • How do you store input from keyboard into a string array

    I am trying to learn java and one of the programs I am trying to write needs to be able to accept a machine hostname at the keyboard and stuff it into a string array element. I am sure I will be using something along the lines of:
    BufferedReader in = new BufferedReader(new InputStreamReader(
                             System.in));
                   String str = "";
                   System.out.print("Enter a FQDN to look up: ");
                   str = in.readLine();
    but how do I get the input stuffed into hostname[ ].
    Any hints or assistance will be appreciated.
    Michael

    Well part of. I need to be able to take a random number of hostnames (ie. mblack.mkblack.com, fred.mblack.com, joe.mblack.com, ...) and after the user presses the enter key between each entry, the inputted information is stored in an array element. for example with the three shown above the array would look like this after the user finished.
    hostname {"mblack.mblack.com","fred.mblack.com","joe.mblack.com"};
    the algorithm would be
    Prompt for hostname
    get user input and press enter
    store hostname into array element
    prompt for next hostname or enter with no input to complete entry and execute lookup.class methods.
    I have the program written and working fine if I use a static array where I put the hostnames in the list, but cannot figure out how to get the information from the keyboard to the array element.
    Thanks for the help though, the response is very much appreciated.
    Michael

  • IP: Use of input-ready variable in planning function

    Dear all,
    I'm using an input-ready variable for fiscal year (0P_FYEAR) in my input ready query. It's used for restricting my columns.
    I'd like to use the value of this variable in my planning function and I use VARV for that in the FOX.
    However, when implementing the pl.function as a button in the BEx Analyzer I need to fill in the static parameters the VAR_VALUE_1 with a value.
    If I delete this line from the static parameters my plfunction end swith an error.
    I like this value of course to be filled with value of fiscal year entered by the user when starting the query.
    Does anybody know how to solve this?
    Kind regards, Harjan

    Hi Johannes,
    Thanks for all the useful information!
    Another thing on using PF.
    I've got two workbooks with different queries but using <u>same</u> filter.
    Queries differ in keyfigures, but are on same cubes in MultiProvider.
    I can run the workbooks simultaneously: no locks occur.
    I've got two planning functions that make calculations on the keyfigures entered in the workbook.
    However when I inplement the PF's in both workbooks and assign the dataprovider as filter, i do get locks!
    So, the PF also uses the same filter, but doesn't take into account the different keyfigures.
    In the fox-formula i don't have the option to make conditions on keyfigure values (field keyfigname), neither to enter them in the filter.
    Do you have any thoughts on this?
    <u>Second</u> point:
    When i filter on a navigational attribute and execute the pf, i get errors on my pf.
    It states it can't find the value of the characteristic to which the navigational attr belongs. F.i. when i filter on nav attr 'customer group'  (attr of char 'customer') and execute pf, the system gives an error on the value of char 'customer'.
    It states: value of characteristic customer is notincluded in the selection.
    Any thoughts on this one?
    Thanks in advance!
    Kind regards, Harjan

  • How to use one Bex Variable for two purposes in one query?

    Hi,
    I want to prompt for a UOM in a query. Then I want to use that one UOM variable to do 2 tasks in the query:
    1. Perform a UOM conversion on one restricted key figure (no filtering)
    2. Filter in a second restricted key figure (no conversion)
    How would I use a variable (or two?) to do this? I do not want to have 2 UOM prompts.
    Thanks!
    Gregg

    Oh, it all seems so easy now!  Hindsight 20-20...
    Solution was to create a new input ready variable for Unit.
    1. Restrict the key figures which need restricting using new variable
    2. For conversions, in BI backend us T-code RSUOM and create new conversion type associated with new variable. Then for each key figure needing conversion, set the conversion parameter to use the new conversion type.
    Between both 1 & 2 above, the same variable is used & thus prompted only once.
    Solution works perfectly.... as it should. Hope this helps someone else!

  • SEM - Balance Scorecard: Run-time Variable for value

    Good day,
    I need to create a CPM Variable for a value that should be entered by the user at run-time. Could you please inform how this would be done?
    Regards
    Grant Carelse

    Hi Ravi,
    Created a basic query with a key figure (Actual Capital Spend) and the characteristic value (Number of Households, this should be manually entered when the KPI is accessed on the scorecard by the user viewing the KPI). What has occurred in the design process is that the CPM variable for number of households does not show up when linking the query to the value field in the Measure. Only the variable folders are showing up.
    Even if the CPM Variable does show up, I was thinking that this characteristic value has to be linked to a second value field so that I can divide the Actual Capital spend by the number of households. Would I be able to do this?
    Regards
    Grant Carelse

  • MIBs required for "HP Smart Array P420/1GB FBWC"

    Hi,
    One of our customer purchaged "HP Smart Array P420/1GB FBWC
    " to integrate that we required the following details.
    -          MIB
    -          Alarm Documentation
    -          Alarm List
    -          Features like AlarmUpload
                     Is it supported?
                     If yes how to perform(eg., set based/get based etc.,)
    Could you please help in getting the above details for "HP Smart Array P420/1GB FBWC"
    Thanks in advance.
    Ezhil

    Hi:
    You may also want to post your question on the HP Business Support Forum -- ProLiant Storage Systems section:
    http://h30499.www3.hp.com/t5/ProLiant-Storage-Systems/bd-p/itrc-265#.VG4Bo3ktC9I

  • Disabling entry into empty ARRAY element ?

    LV 2010.0
    I have a UI problem.
    I have a cluster of input stuff, arranged as a row.
    On a front panel, I have an array of these rows, so the user can edit the test mode in progress and the modes upcoming.
    The array has the INDEX control hidden.
    I have room for 15 rows on the panel.
    15 is enough for 90% of the cases, but for those others, I use the vertical scrollbar of the array.
    The problem is, if I have 20 rows (0..19) in the array, the scrollbar will let me scroll down and show me element #20, which is empty.
    It will allow me to enter something into row 20, and then it will allow me to scroll to #21, etc., etc.
    I want to prevent that.  I have an APPEND button for creating a row the way I want it.  Entering zeroes into the row is not good (some fields are P-I-D constants).
    Not to mention that the highlighting is done via a color box behind the number fields, when this would-be row appears, the default color is black, which is dimmed by the fact that it's non-existent to an ugly gray. Which matches the text color so it's one big gray stripe.
    I already have code to detect a mouse click and highlight the row you click on.  So I can detect a click on the bogus row and discard the event, meaning you can't actually create a new element.  That's necessary for the safety of the machine and that all works fine.
    But how can I stop it from appearing?
    If there are 15 or fewer rows in the test, I set the NUMROWS to however many I have, and hide the scrollbar.  That's fine.  But I need the scrollbar for the bigger tests. But it insists on showing me N+1.
    I could conceivably poll the INDEX VALUES property and if it gets to the point where the bogus row is showing, I change it back.  But that is an ugly hack, big-time.
    I don't see any properties for adjusting the limits of the scrollbar. I don't see a property for DON'T ALLOW NEW ELEMENTS.
    Is there something I can do?
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks
    Solved!
    Go to Solution.

    You can get a bit fancier for controlling the array by adding your own navigation and insert buttons. When you want to prevent someone from adding something you can simply disable the add (+). Even if the type something in you can remove it when they atempt to add it. Here is a basic example of what I am talking about.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot
    Attachments:
    Array button control test.vi ‏47 KB

  • Change a property of a specifc array element (array of type defs)

    If I have an array of elements, and I want to change aproperty of one specific element, at position X, is there a way to do this?
    Basically, I have an array of string indicators indicating certain tests attached to certain ports, and I want to change the text to bold on certain indicators, and i want to color certain indicators green or red.  Any chance in an array or clusters only? 
    Thanks Guys.

    While you can't change the properties for a single array element, there are solutions.
    For the background color, you can turn the array element into a cluster of your string (which would be transparent) and a color box which will be the background. You can then change the value of the color box and the color will change.
    For the bold text, I think your only option will be to get rid of the string control and make the array element a picture control instead. Using the picture VIs, you can draw a colored rectangle and then place text inside it (and each element can have different text properties). That way, you won't even need the color box.
    Try to take over the world!

  • Getting input for atleast one variable present in the report

    Hi All,
    I want to create a report with the below requirement.
    If user didn't enter the value for any of the customer exit varaibles(ZCALDAY, ZCALMNTH and ZCALYEAR), then it should not allow user to generate the report. It should give a message or popup and return to the selection screen for getting the value for the input variable. Basically, it should get input for atleast one variable.
    Please help me in this issue.
    Regards,
    Yokesh Kumar.

    Hi All,
    I have written the below code for my requirement.
    when 'zcalday' or 'zcalmnth' or 'zcalyear'.
          DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT,
                      count type i.
          IF I_STEP = 3.
            count = 0.
            LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'zcalday' or VNAM = 'zcalmnth' or VNAM = 'zcalyear'.
              IF LOC_VAR_RANGE-LOW is initial.
                count = count + 1.
              ENDIF.
            ENDLOOP.
            if count EQ 3.
              CALL FUNCTION 'RRMS_MESSAGE_HANDLING'
                EXPORTING
                I_CLASS = 'RSBBS'
                I_TYPE = 'I'
                I_NUMBER = '000'
                I_MSGV1 = 'Please give inout for atleast one varialbe''.
                RAISE no_replacement.
             endif.
          ENDIF.
    Is there any fault in the below code? Please let me know if there is anything to correct...
    Regards,
    Yokesh Kumar.

Maybe you are looking for

  • Amount of temporary tablespace size used for index rebuild

    Hi All, I want to know approximate amount of temporary tablespace size used for index rebuild. I need this information to avoid the insufficient temporary tablespace error during the huge index rebuild. Is there a query or procedure to find it out. T

  • The best way to do paging and get total rows count given a sql statement

    Hi, Just got a quick question.... what is the best way to do paging as well as the total rows count given by a sql statement. e.g. "select * from emp" 1. I need to know the total row count for this statement. 2. I also need to do a 10 rows per page..

  • Sinc to new ipod, but no videos

    i received a newe ipod, connected it to computer, itunes synced all music, but only 3 music videos. The rest seemed to have vanished.What do I do? at least 10-15 music videos gone

  • How to print mirror images?

    Hi, I am trying to print some images for a Tshirt transfer. I can't find the mirror image setting? I am using an HP 6200, I can't seem to find the menu to print the morror image. Thanks

  • Clearing Contacts list

    Got an iPhone 4 yesterday, and paid too little attention when registering/syncing it. My Mac's address book had large numbers of entries which are now totally irrelevant and which now appear in the Contacts on the iPhone. I have (belatedly) tidied up