Adding next element into an array

I can manage to add the first element as I want in a for loop, however, the next element simple overwrites the index array element. I would like it to add the next element to the next space in the array.
This is how I have declared it.
private String stuff[];
This is it initialised, with 10 as an example.
Stuff = new String[10];
This is inside a method with a string tokenizer ("st").
while(st.hasMoreTokens())
boolean comparsion = enter.equals(st.nextToken());
if(comparison == true)
stuff(i) = st.nextToken(); <<the brackets next to stuff () are meant to be [] but forum formats to italic
I am trying to add values that match what is entered in a parameter (enter is the parameter variable) against the tokens in a file. It seems to add the first match in the array and then if run again it replaces this a new match and is not added as the second element. Any help much appreciated.
Thanks.

Use the code tags as follows next time:
your codeThank you.
Your problem is you do not increment i;
stuff = new String[10];
int i = 0; // declare and initialize i
while (st.hasMoreTokens())
  boolean comparsion = enter.equals(st.nextToken());
  if (comparison) // no need to == true
    stuff[i] = st.nextToken();
    i++:  // increment i
}

Similar Messages

  • Hihow to insert 2 elements into 2D array?

    Hi I had a hard time figuring out how to insert 2 elements into 2D arrays. 
    I tried using replace and insert array functions but it does not work right way.
    I am using LV7.1. See the pic below.
    How do I insert elements in that way?
    Pls advise
    Clement

    Well, "replace array subset" is not the right tool, because it keeps the size of the array constant. Insert into array only works for entire rows or columns.
    You need a hybrid approach, because you want to insert elements at the beginning of column 1 while padding the remaining columns to the new lenght of column 1. This won't be efficient but there are plenty of ways to do that (here is one example with DBL arrays, should work equally well for string arrays as in your case).
    How much flexibility do you need? Is it always at the beginning of the first column? Are the arrays huge (=is performance an issue)? Is this a rare operations or do you constantly need to do this (e.g. inside a loop).
    In any case this seems like a rather arbitrary and somewhat silly operation. What is the practical purpose?
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    WeirdMerge.vi ‏21 KB

  • How to insert elements into an array after each iteration of a for loop

    I am new to labview and working on an application where I am supposed to store an element into an array (without overwriting) after each iteration in a for loop. I have tried using Build Array Function keeping the indicator outside the for loop and played with indexing but didn't work. Please suggest me an idea how to do it.
    Thanks
    Solved!
    Go to Solution.

    Thank you for your suggestion.Here is my actual application attached . In the first image, a difference in time is evaluated and an enum const of insert into array is passed to the shift register where it takes to Insert element into array phase (Second image). I need to enter the time difference into an array after every loop iteration. Please have a look and could you let me know where I am mislead.
    Attachments:
    Image 1.JPG ‏88 KB
    Image 2.JPG ‏71 KB

  • Using Enter key from numeric keypad to enter and switch to next element in an array control

    Hello all,
    I have a question regarding a simple but annoying problem, of which I did not found a solution yet.
    I have written an application in which I have to enter data manually in a numeric array control.
    If I want to enter the value and go to the next element in the array control, i am forced to use the Tab key on my keyboard, or risk RSI using the mouse.
    How can I assign the Enter key of the numeric keypad section of my keyboard to to the same as the Tab key?
    Kind regards,
    Raymond

    [email protected] wrote:
    Can you convert the example in a image or can you convert in to 8.2.1 version?.
    Best regards
    Saved in 8.2.1 for you.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Change Array Event.vi ‏16 KB

  • Adding an element in an array of cluster of 2 elements

    Hi all,
    I have a 1D array containing a cluster of 2 numeric elements (= 2 rows of 100 values).
    From this array, collecting new data in for loop, I want to create another array containing a cluster with 9 elements: in each for I want to add an element (= like one row).
    After this, I want to compare data from one element with a fixed value, and when the value is find in the element, I want to extract the values of the 8 other elements at this point.
    Thanks
    Dze

    Sorry I didn't understand you well. To use only arrays, you'll need 3D arrays, as you can see in the example attached. I've made two variants, one with your method (don't know if there's an easyer one) and one with the method I think is easyer, after that, you can search in the 3D array easyer that in the array of clusters of arrays (uff...). If I misanderstood you again, please let me know.
    Hope this helps
    Attachments:
    arrayclusterarray.llb ‏50 KB

  • Insert element into array (manually)

    Hello,
    I have an issue with the insertion of elements into an array. Here's the situation;
    - I've declared an array of strings as a local variable (let's say a 10-element array)
    - All the fields of the array have been filled with strings.
    - I would like to insert a new element into the array (for example at index 3)
    When I go to the "bounds" property and increase the array's bounds, the new element is added at the end of the array. Is there a means to insert the new element in any other position ?
    Thanks
    Zouz

    If you call a PropertyObject.SetVal<DataType>ByOffset() method, you can pass PropOption_InsertElement to the options parameter.

  • How to delete an  element in an array...(simple way)

    hi,
    Newbie here... please help how to delete an element in an array list?
    there are alot of codes but they're complicated for a newbie like me..
    (simple codes would be better ..:) thank you...

    makk_88 wrote:
    since u want the simple method.....
    just overrite the position of the element that need to be deleted with the next element in the array..
    by doing this, element need to be deleted will not be accessibe..
    i think u got..what i'm saying.
    thnx..Mak,
    Say we wish to delete the second element of an array a[1]. Do you really believe that a[1] = a[2] somehow magically deletes a[1]? I really don't think so Tim.
    Two eggs, minus 1, equals two eggs? Interesting theory, but I think you're probably wrong.
    *@OP:* My advise is just use an ArrayList.
    Cheers. Keith.

  • Can we include ArrayList into a array

    HI,
    i am newer to java.
    Can we include ArrayList element into an array,
    give the sample code.
    Regards,
    kumar

    Fine. But Here, all of my ArrayList elements are
    string.
    I have to assign all the ArrayList elements into the
    the array.
    Is it possible. give the sample code.Yes say your array list has all string elements here is how you do it...
    ArrayList<String> alist = new ArrayList<String>();
    alist.add("1");
    alist.add("2");
    alist.add("3");
    alist.add("4");
    alist.add("5");
    String arrayStrings[] = alist.toArray(new String[alist.size()]);
    NOTE: Works with J2SE 5.0 or above
    and for 5.0 below the below could be a solution.
    public static void main(String[] args){
    Test test = new Test();
    // Syntatically incorrect
    String[] s1 = new String(lst.size());
    // Would get a Type Cast Exception as ArrayList.toArray() returns Object[] not String[]
    s1 =lst.toArray();
    // and btb what test.toArray() do ??
    //s1 = test.toArray();
    }you may have to restructure it to
    public static void main(String[] args)
      Test test = new Test();
       int size = lst.size();
       String ArrayString[] = new String[size];
       Object k[] = list.toArray();
       for(int i=0 ; i < size; i++)
         ArrayString[i] = (String)k;
    Hope that might be the one...
    REGARDS,
    RaHuL

  • How to add elements into java string array?

    I open a file and want to put the contents in a string array. I tried as below.
    String[] names;
    s = new Scanner(new BufferedReader(new FileReader("outfile.txt")));
    while (s.hasNext()) {
                    String item = s.next();
                    item.trim();
                    email = item;
                    names = email;
                }But I know that this is a wrong way of adding elements into my string array names []. How do I do it? Thanks.

    Actually you cannot increase the size of a String array. But you can create a temp array with the lengt = lengthofarray+1 and use arraycopy method to copy all elements to new array, then you can assign the value of string at the end of the temp array
    I would use this one:
    String [] sArray = null;
    s = new Scanner(new BufferedReader(new FileReader("outfile.txt")));
    while (s.hasNext()) {
        String item = s.next();
        item.trim();
        email = item;
        sArray = addToStringArray(sArray, email);
    * Method for increasing the size of a String Array with the given string.
    * Given string will be added at the end of the String array.
    * @param sArray String array to be increased. If null, an array will be returned with one element: String s
    * @param s String to be added to the end of the array. If null, sArray will be returned.(No change)
    * @return sArray increased with String s
    public String[] addToStringArray (String[] sArray, String s){
         if (sArray == null){
              if (s!= null){
                   String[] temp = {s};
                   return temp;
              }else{
                   return null;
         }else{
              if (s!= null){
                   String[] temp = new String[sArray.length+1];
                   System.arraycopy(sArray,0,temp,0,sArray.length);
                   temp[temp.length-1] = s;
                   return temp;
              }else{
                   return sArray;
    }Edited by: mimdalli on May 4, 2009 8:22 AM
    Edited by: mimdalli on May 4, 2009 8:26 AM
    Edited by: mimdalli on May 4, 2009 8:27 AM

  • How to put data into a array element in the BPEL

    Hi,
    I have a element in the WSDL which is of type Array. (i.e accepts unlimited data for the same element). How should i put a data into a array in the BPEL.
    Example:
    The below Example gives u an idea about wht iam asking:pasting a piece of my requirement:
    <s:element minOccurs="0" maxOccurs="1" name="parameters" type="tns:ArrayOfCSParameters" />
    <s:complexType name="ArrayOfCSParameters">
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="unbounded"
    name="CSParameters" nillable="true" type="tns:CSParameters" />
    </s:sequence>
    </s:complexType>
    <s:complexType name="CSParameters">
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="RevenueItem" type="tns:RevenueItem" />
    <s:element minOccurs="0" maxOccurs="1" name="AccountURIs" type="tns:ArrayOfString" />
    <s:element minOccurs="0" maxOccurs="1" name="GroupURIs" type="tns:ArrayOfString" />
    <s:element minOccurs="1" maxOccurs="1" name="Percentage" nillable="true" type="s:decimal" />
    </s:sequence>
    <s:attribute name="Version" type="s:decimal" use="required" />
    <s:attribute name="URI" type="s:string" />
    </s:complexType>
    Any suggestion is appreciated.
    Regards
    pavan

    You have 2 options i guess.
    Use the transformation and the for-each to construct the array-list
    or like Richard said, use a loop in bpel, assign in the loop an variable of element type="CSParameters" and append this variable to your variable with accepts the arraylist.

  • How do I convert a 1-D array of cluster of 5 elements into a 2-D array of numbers? (history data from a chart)

    Hello,
    in my vi I have a chart with 5 Plots displaying measurement data.
    The user should be able to save all the history data from the chart at anytime. (e.g. the user watches the chart and some event happens, then he presses a "save"-button)
    I know, that I can read out the history data with a property node. That is not the problem. The problem is, how do I handle the data? The type of the history data is a 1-D array of cluster of 5 elements.
    I have to convert that data somehow into a 2 D-array of numbers or strings, so that I can easily save it in a text-file.
    How do I convert a 1-D array of cluster of 5 elements into a 2-D array of numbers?
    I use LabVIEW 7.1
    Johannes
    Greetings Johannes
    Using LabVIEW 7.1 and 2009 recently
    Solved!
    Go to Solution.

    Gerd,
    thank you for the quick response and the easy solution.
    Look what I did in the meantime. I solved the problem too, but muuuch more complicate :-)
    And I have converted the numbers to strings, so that I can easily write them into a spreasheet file.
    Johannes
    Message Edited by johanneshoer on 04-28-2009 10:39 AM
    Greetings Johannes
    Using LabVIEW 7.1 and 2009 recently
    Attachments:
    SaveChartHistory.JPG ‏57 KB
    SaveChartHistory.JPG ‏57 KB

  • I want to create an array that goes into a case structure where each element in the array is an individual case and gets done in order

    I want to create an array that goes into a case structure where each element in the array is an individual case and gets done in order. Any ideas, I've been playing with the idea but have had no luck, is this even possible?

    Hi,
    Please check it out the attached Vi.. Is this you need?
    Sasi.
    Certified LabVIEW Associate Developer
    If you can DREAM it, You can DO it - Walt Disney
    Attachments:
    Event.vi ‏11 KB

  • Adding pictures into an Array?

    The following is a BlackJack Program my group and I made. So far, it seems to work and would likely net us a 100% when we hand it in. However, we wish to go that extra mile and add pictures, cards in particular, something that should obviously be in any card game! I've been fiddling around with ImageIcon and Image but I don't have a clue how to implement these or how to get them working correctly. Also, it would be best if the pictures could be loaded into an array, which would allow the program to function basically the same way with little editing.
    //Import various Java utilites critical to program function
    import java.awt.* ;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Random;
    import java.lang.String;
    public class BlackJackExtreme extends JFrame {  
      Random r = new Random();  //Assigning "r" to randomize
      int valueA;  //Numerical Value of player Cards
      int valueB;
      int valueC;
      int valueD;
      int valueE;
      int valueAC;  //Numerical Value of computer Cards
      int valueBC;
      int valueCC;
      int valueDC;
      int valueEC;
      int playerVal;  //Numerical total value of player cards
      int playerVal2;
      int playerValT;
      int compVal;  //Numerical total value of computer cards
      int compVal2;
      int compValT;
      int counter;  //A counter
      String playVal; //String value for Numerical total value of player cards
      String cVal;   //String value for Numerical total value of computer cards
      private JLabel YourCard;   //Initializing a title label
      private JLabel CCard;  //Initializing a title label
      private JLabel Total;   //Initializing a title label
      private JLabel CTotal;  //Initializing a title label
      private JLabel Win;   //Initializing a Win label
      private JLabel Lose;  //Initializing a Lose label
      private JLabel Bust;  //Initializing a Bust label
      private JButton Deal;   //Initializing a button
      private JButton Hit;   //Initializing a button
      private JButton Stand;   //Initializing a button
      private JButton Exit;   //Initializing a button
      private JTextArea TCompVal;     //Initializing textbox for computer values
      private JTextArea TotalVal;
      private JLabel CardOne;  //Initializing a label for player card 1
      private JLabel CardTwo;  //Initializing a label for player card 2
      private JLabel CardThree;  //Initializing a label for player card 3
      private JLabel CardFour;   //Initializing a label for player card 4
      private JLabel CardFive;   //Initializing a label for player card 5
      private JLabel CCardOne;   //Initializing a label for computer card 1
      private JLabel CCardTwo;   //Initializing a label for computer card 1
      private JLabel CCardThree;   //Initializing a label for computer card 1
      private JLabel CCardFour;   //Initializing a label for computer card 1
      private JLabel CCardFive;   //Initializing a label for computer card 1
      private JPanel contentPane;
      public BlackJackExtreme() {
        super();
        initializeComponent();     
        this.setVisible(true);
      private void initializeComponent() {   
        YourCard = new JLabel("These are your cards");
        CCard = new JLabel("These are the computers cards");
        Total = new JLabel("Your total is: ");
        CTotal = new JLabel("Computer total is: ");
        TCompVal = new JTextArea();  //Box for computer values
        TotalVal = new JTextArea();  //Box for player values
        Win = new JLabel("You win!");  //Label for a Win
        Lose = new JLabel("You lose!");  //Label for a Loss
        Bust = new JLabel("You both Bust!");  //Label for a Bust
        Deal = new JButton();  //Button
        Hit = new JButton();  //Button
        Stand = new JButton();  //Button
        Exit = new JButton();  //Button
        CardOne = new JLabel("");  //Label for Player Card 1
        CardTwo  = new JLabel("");  //Label for Player Card 2
        CardThree = new JLabel("");  //Label for Player Card 3
        CardFour = new JLabel("");  //Label for Player Card 4
        CardFive = new JLabel("");  //Label for Player Card 5
        CCardOne = new JLabel("");   //Label for Computer Card 1
        CCardTwo  = new JLabel("");  //Label for Computer Card 2
        CCardThree = new JLabel("");  //Label for Computer Card 3
        CCardFour = new JLabel("");  //Label for Computer Card 4
        CCardFive = new JLabel("");  //Label for Computer Card 5
        contentPane = (JPanel)this.getContentPane();
        //Assigns function and ability to the various buttons
        Deal.setText("Deal");
        Deal.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Deal_actionPerformed(e);
         Stand.setText("Stand");
        Stand.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Stand_actionPerformed(e);
            Exit.setText("Exit");
        Exit.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Exit_actionPerformed(e);
         Hit.setText("Hit");
        Hit.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Hit_actionPerformed(e);
        //Determines the arrangement of the various buttons, labels, and other GUI objects
        contentPane.setLayout(null);
        addComponent(contentPane, YourCard, 15,1,150,50);
        addComponent(contentPane, CCard, 325,1,200,50);
        addComponent(contentPane, Deal, 15,415,100,35);
        addComponent(contentPane, Hit, 125,415,100,35);
        addComponent(contentPane, Stand, 235 ,415,100,35);
        addComponent(contentPane, Exit, 435 ,415,100,35);
        addComponent(contentPane, CardOne, 25,35,50,50);
        addComponent(contentPane, CardTwo, 110,35,50,50);
        addComponent(contentPane, CardThree, 25,120,50,50);
        addComponent(contentPane, CardFour, 110,120,50,50);
        addComponent(contentPane, CardFive, 65,200,50,50);
        addComponent(contentPane, CCardOne, 350,35,50,50);
        addComponent(contentPane, CCardTwo, 450,35,50,50);
        addComponent(contentPane, CCardThree, 350,120,50,50);
        addComponent(contentPane, CCardFour, 450,120,50,50);
        addComponent(contentPane, CCardFive, 400,200,50,50);
        addComponent(contentPane, Win, 300,300,70,50);
        addComponent(contentPane, Lose, 300,300,70,50);
        addComponent(contentPane, Bust, 300,300,100,50);
        addComponent(contentPane, Total, 100,350,150,50);
        addComponent(contentPane, TotalVal, 200,365,25,25);
        addComponent(contentPane, CTotal, 300,365,150,25);
        addComponent(contentPane, TCompVal, 425,365,25,25);
        //Sets the "outcome" labels invisible on program execution
        Win.setVisible(false);
        Lose.setVisible(false);
        Bust.setVisible(false);
        //Determines size of program window
        this.setTitle("BlackJack");
        this.setLocation(new Point(220,185));
        this.setSize(new Dimension(555,500));
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
      private void addComponent(Container container, Component c, int x, int y, int width, int height){
        c.setBounds(x,y,width,height);
        container.add(c);
      //The DEAL button
      public void Deal_actionPerformed(ActionEvent e) {
        //Correctly resets the display after first round of use
        Hit.setVisible(true);
        Stand.setVisible(true);
        Win.setVisible(false);
        Lose.setVisible(false);
        Bust.setVisible(false);
        CardThree.setVisible(false);
        CardFour.setVisible(false);
        CardFive.setVisible(false);
        TotalVal.setText("");
        TCompVal.setText("");
        //Card Array - Values assigned to cards
        String[] cardnames = new String[15];
        cardnames[0] = "Error";
        cardnames[1] = "Error";
        cardnames[2] = "Two";
        cardnames[3] = "Three";
        cardnames[4] = "Four";
        cardnames[5] = "Five";
        cardnames[6] = "Six";
        cardnames[7] = "Seven";
        cardnames[8] = "Eight";
        cardnames[9] = "Nine";
        cardnames[10] = "Ten";
        cardnames[11] = "Jack";
        cardnames[12] = "Queen";
        cardnames[13] = "King";
        cardnames[14] = "Ace";
        //Randomize Card Values
        valueA = r.nextInt(13)+2;
        valueB = r.nextInt(13)+2;
        valueAC = r.nextInt(13)+2;
        valueBC = r.nextInt(13)+2;
        //Displays Card
        CardOne.setText(cardnames[valueA]);
        CardTwo.setText(cardnames[valueB]);
        CCardOne.setText(cardnames[valueAC]);
        CCardTwo.setText(cardnames[valueBC]);
        //Value Correction for Player Cards
        if (valueA == 11 || valueA == 12 || valueA == 13) {
          valueA = 10;  }
        if (valueA ==14){
          valueA = 11;    }
        if (valueB == 11 || valueB == 12 || valueB == 13) {
          valueB = 10;    }
        if (valueB ==14){
          valueB = 11;    }
        //Value Correction for Computer Cards
        if (valueAC == 11 || valueAC == 12 || valueAC == 13) {
          valueAC = 10;  }
        if (valueAC ==14){
          valueAC = 11;    }
        if (valueBC == 11 || valueBC == 12 || valueBC == 13) {
          valueBC = 10;    }
        if (valueBC ==14){
          valueBC = 11;    }
        //Computer Hand Value Calculations
        compVal = valueAC + valueBC;
        //Assigns addition cards to computer
        if (compVal <= 15) {
          valueCC = r.nextInt(13)+2;
          CCardThree.setText(cardnames[valueCC]);
          if (valueCC == 11 || valueCC == 12 || valueCC == 13) {
           valueCC = 10;    }
          if (valueCC ==14){
            valueCC = 11;    }
          compVal += valueCC;    }
        //Changes the Integer value of player and computer hands into a String value
        cVal = Integer.toString(compVal);  
        playerVal = valueA + valueB;
        playVal =  Integer.toString(playerVal);
        TotalVal.setText(playVal);
        Deal.setVisible(false);
        CCardOne.setVisible(false);
      //The HIT button
      public void Hit_actionPerformed(ActionEvent e) {
        //A counter that changes the specific function of the HIT button when it is pressed at different times
        counter++;
          if (counter ==3){
          Hit.setVisible(false);
        //Card Array - Values assigned to cards
        String[] cardnames = new String[15];
        cardnames[0] = "Error";
        cardnames[1] = "Error";
        cardnames[2] = "Two";
        cardnames[3] = "Three";
        cardnames[4] = "Four";
        cardnames[5] = "Five";
        cardnames[6] = "Six";
        cardnames[7] = "Seven";
        cardnames[8] = "Eight";
        cardnames[9] = "Nine";
        cardnames[10] = "Ten";
        cardnames[11] = "Jack";
        cardnames[12] = "Queen";
        cardnames[13] = "King";
        cardnames[14] = "Ace";
        //Randomize Card Values
        valueC = r.nextInt(13)+2;
        valueD= r.nextInt(13)+2;
        valueE = r.nextInt(13)+2;
        //Determines which card is being hit, as well as randomizing a value to that location
        if (counter == 1) {
          CardThree.setText(cardnames[valueC]);
          playerVal2 = 0 + (valueC);      
          CardThree.setVisible(true);    }
        if (counter == 2) {
          CardFour.setText(cardnames[valueD]);  
          playerVal2 += (valueD) ; 
          CardFour.setVisible(true);    }
        if (counter == 3) {
          CardFive.setText(cardnames[valueE]);
          playerVal2 += (valueE);
          CardFive.setVisible(true);    }
        //Value corrections for player cards
        if (valueC == 11 || valueC == 12 || valueC == 13) {
          valueC = 10;    }
        if (valueC ==14){
          valueC = 11;    }
        if (valueD == 11 || valueD == 12 || valueD == 13) {
          valueD = 10;    }
        if (valueD ==14){
          valueD = 11;    }
        if (valueE == 11 || valueE == 12 || valueE == 13) {
          valueE = 10;    }
        if (valueE ==14){
          valueE = 11;
        //Changes the Integer value of player and computer hands into a String value
        playerValT = playerVal + playerVal2;
        playVal =  Integer.toString(playerValT);
        TotalVal.setText(playVal);
        //The STAND button
        private void Stand_actionPerformed(ActionEvent e) {
          //Correctly assigns player value if HIT button is never pressed
          if (counter == 0){
            playerValT = playerVal; }    
          //Reveals the unknown computer card
          CCardOne.setVisible(true);
          //Determines the winner and loser
          if (playerValT <= 21 && compVal < playerValT) {
            Win.setVisible(true); }
          else if (playerValT <= 21 && compVal > 21) {
            Win.setVisible(true); }
          else if (playerValT >21 && compVal > 21) {
            Bust.setVisible(true); }
          else if (compVal <= 21 && playerValT < compVal){
            Lose.setVisible(true);}
          else if (compVal <= 21 && playerValT > 21) {
            Lose.setVisible(true); }
          else if (compVal == playerValT){
            Lose.setVisible(true); }
          //Configures program and display for next use
          Deal.setVisible(true);
          Stand.setVisible(false);
          Hit.setVisible(false);
          counter = 0;
          TCompVal.setText(cVal);
        //The EXIT button
          private void Exit_actionPerformed(ActionEvent e) {
            System.exit ( 0 );
      public static void main(String[]args) {   
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);   
        new BlackJackExtreme();
      Instead of having a JLabel with "Ace", "Eight", etc appear, how would one make pictures appear? How does one do this with an array?
    Edited by: Funkdmonkey on Jan 1, 2008 7:45 PM

    I guess an array or perhaps better a hashmap where the image is the value and the card (a great place for an enum!) is the key would work nicely. Oh, and you can find a great public domain set of card images here:
    http://www.eludication.org/playingcards.html
    Finally, your code appears to be suffering from the God-class anti-pattern. You would do well to refactor that beast.
    Edited by: Encephalopathic on Jan 1, 2008 8:09 PM

  • Combining two StringBuffer array elements into a single array element

    I just need to know how to combine two stringBuffer array elements into one
    StringBuffer ciphertext [] = new StringBuffer[2];
              StringBuffer s0 = new StringBuffer("11011111111110001001101110110101");
              StringBuffer s1 = new StringBuffer("00010011001101000101011101111001");
              ciphertext[0] = s0;
              ciphertext[1] = s1;
              ciphertext[2] = ciphertext[0].append(ciphertext[1]);I get an array index out of bounds exception:2
    Thanks

    StringBuffer ciphertext [] = new StringBuffer[3];  // legal index values are: 0,1,2

  • Adding ouput into appended array

    Hi,
    I have a labview which gives a single element as an output after each test run. Is it possible to add this single dynamic output to previous data resulting into an Array(1-D).
    Thank you for your Help!!

    Thanks Mike & Muks for your reply.
    In my case is that when I run the program once it returns a single ouput. The second time I run the program it provides with an different value of output as opbvious. But at the end of say ten test runs. I wan to to see all the ten outputs in an array. Is it possible?
    I am trying to write an read the output after each test run. Is it sensible? or Is there any other way?
    I am attaching my program for your reference. and a snap shot of the final output (TOF) which i want to retrive data for all ten runs.
    Thank You
    Attachments:
    PAR_LAB_ATT_00_09_E.vi ‏1123 KB
    sanp_1.PNG ‏31 KB

Maybe you are looking for