Adding a char to an array

Hi
I've got the following code to add a char to an array but I keep getting a runtime error and can't see what i'm doing wrong
int x = 0;
String RowR[] = {"", "", ""};
for (int i=0; i<co_ordinates.length(); i++)
RowR[x] = RowR[x] + co_ordinates.charAt(i);
if (x>2)
x= 0;
else
x = x + 1;
               }Thanks
Edited by: jclegs on Nov 23, 2007 4:04 AM
Edited by: jclegs on Nov 23, 2007 4:04 AM

Sorry here is the exceptions
z
e
r
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 3
    at EncryptedCoordinates.encrypt(EncryptedCoordinates.java:38)
    at P6_Client.sendData(P6_Client.java:94)
    at P6_Client$ButtonHandler.actionPerformed(P6_Client.java:157)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6038)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
    at java.awt.Component.processEvent(Component.java:5803)
    at java.awt.Container.processEvent(Container.java:2058)
    at java.awt.Component.dispatchEventImpl(Component.java:4410)
    at java.awt.Container.dispatchEventImpl(Container.java:2116)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
    at java.awt.Container.dispatchEventImpl(Container.java:2102)
    at java.awt.Window.dispatchEventImpl(Window.java:2429)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Process completed.Thanks

Similar Messages

  • Adding data to a tree array

    How to add data from the database to a treenode declared as an array?
    for example,adding database data to top[0]...like empno values

    Atb wrote:
    Basically I'm doing DES from scratchWoah! Stop right there.
    Why do you do that? You know that implementing an encryption system is very hard and very easy to get wrong. Even if it is a well known one.
    Do you plan to use this in a production environment or do you simply want to try it to have done it once?
    If you plan to use it, then please do yourself a favor and stop it. If you simply want to have it implemented once, then don't let me stop you.
    Also: If you really want to go ahead, then you really should learn how to do bit manipulation using the "real" data structures (i.e. BitSet or even int/long depending on performance requirements and amount of data handled).
    You can even write your own wrappers with a usefull toString() implementation to keep that "easy-to-check visually" feature.

  • How to search a char in 2d array any direction

    the method will take a string argument and convert them into char and try to find them in a 2d array.
    It is more like a word puzzle(wordSearcher).Here's what i've done so far...
    public void find(String word)
    for(int a = 0; a < word.length(); a++) {
    char oneChar = word.charAt(a);
    String oneStringchar = String.valueOf(oneChar);
    // Searching through in South Direction
    for(int i = 0; i < g.length; i++) {
    for(int j = 0 ; j < g.length ; j++) {
    if (oneChar == g[j]) {
    canvas.draw(oneStringchar, (i * WORD_SIZE) + POS_X, (j * WORD_SIZE) + POS_Y);
    }

       // Searching through in South Direction
       for(int i = 0; i < g.length; i++) {
          for(int j = 0 ; j < g.length ; j++) {
    if (oneChar == g[i][j]) {
    canvas.draw(oneStringchar, (i * WORD_SIZE) + POS_X, (j * WORD_SIZE) + POS_Y);

  • Adding time stamp to table/array

    Hi,
    In my posted VI I am displaying some collected temperature data on a table.  What I am having trouble with is getting the time data to work properly on the table.  When I set the include time data to true, it reads out the time as 1904 etc. I'm not sure if it's possible for me to include a time stamp in my array because when I try to convert a time stamp to a double precision float, the output is still a cluster, and thus cannot be added to the array.  I've also tried to convert the array to a string and concatenate the time stamp on, but the signals input for the table does not accept strings, and because I would eventually like to export this table to a spreadsheet in a file, I don't really want to link the strings to the indicator directly.  I've tried to work with the instrument as well, but when I read time data from it it gives it back in the form of multiple numbers, such as 2008, 8, 28, 13, 30, 31.12 and I can't consolidate it to one number.  Needless to say, I'm a little stumped and am open to suggestions on how to fix this problem, whether its a quick fix or a change in the way I'm trying to record the data.
    Thanks in advance,
    Mike
    Message Edited by mbeenen on 08-28-2007 03:59 PM
    Attachments:
    Automated Thermal Testing Table.vi ‏75 KB

    Here are the sub VI's that I'm using.  The inner while loop is designed so that the loop will halt immediately when stopped, and not have to finish its current iteration, as the iteration period is intended to be rather long.  I may modify the program to have a programmable start/stop time later, but this is at least my temporary solution.  The purpose of the decimate array function is to seperate out the channel label from the actual data so they can be placed as headers in the Excel function.  The intent was likely not clear with the lack of the SubVI's.  Overall, the display table on the front panel is no longer necessary, it was just for me to see how the table was working in the early stages of development.
    The one issue I had with your suggestion is the fact that I the build waveform function only accepts a 1-D array for the waveform input, and with multiple and variable number of channels being used I'm not sure how I could easily manipulate the data I gather into multiple 1-d arrays.
    As always the help is appreciated,
    Mike
    Attachments:
    Write_Table_To_XL_Mod.vi ‏39 KB
    Conf Temp 2.vi ‏37 KB
    EZ Temperature.vi ‏20 KB

  • Searching a char in 2d array any direction

    the method will take a string argument and convert them into char and try to find them in a 2d array.
    It is more like a word puzzle(wordSearcher).Here's what i've done so far...
    public void find(String word)
    for(int a = 0; a < word.length(); a++) {
    char oneChar = word.charAt(a);
    String oneStringchar = String.valueOf(oneChar);
    // Searching through in South Direction
    for(int i = 0; i < g.length; i++) {
    for(int j = 0 ; j < g.length ; j++) {
    if (oneChar == g[j]) {
    canvas.draw(oneStringchar, (i * WORD_SIZE) + POS_X, (j * WORD_SIZE) + POS_Y);
    }

    Here's something I did a while back, type in any text in the top text area (ensure it's a grid eg 8 x 8),
    then the words to find (one per line) in the lower text area. If found, the co-ords of the word are displayed.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    class WordFinder extends JFrame implements ActionListener
      private static JButton goBtn = new JButton("Search");
      private static JTextArea taLetters = new JTextArea(10,25);
      private static JTextArea taWords = new JTextArea(10,25);
      private static int base = 0;
      private static String letters = "";
      private static String words[];
      private static boolean match = false;
      private static String taWordsNewText = "";
      public static void main(String args[])
        WordFinder wf = new WordFinder();
      public WordFinder()
        super("Word Finder");
        setSize(300,80);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
        Container frame = getContentPane();
        frame.setLayout(new BorderLayout());
        JScrollPane spLetters = new JScrollPane (taLetters);
        JScrollPane spWords = new JScrollPane (taWords);
        goBtn.addActionListener(this);
        JPanel mid = new JPanel(new FlowLayout());
        JLabel infoLbl = new JLabel("'letters' above, 'words to find' below");
        mid.add(infoLbl);
        mid.add(goBtn);
        frame.add(spLetters,BorderLayout.NORTH);
        frame.add(mid,BorderLayout.CENTER);
        frame.add(spWords,BorderLayout.SOUTH);
        pack();
        setContentPane(frame);
      public void actionPerformed(ActionEvent ae)
        letters = "";
        taWordsNewText = "";
        if(lettersAndWordsOK()) findTheWords();
      private static boolean lettersAndWordsOK()
        StringTokenizer st = new StringTokenizer(taLetters.getText(),"\n");
        int count = st.countTokens();
        if(count == 0)
          JOptionPane.showMessageDialog(null,
            "no letter details entered");
          return false;
        String line = "";
        while(st.hasMoreTokens())
          line = st.nextToken();
          if(line.length() != count)
            JOptionPane.showMessageDialog(null,
            "check letters - not a perfect grid \n e.g. 8 x 8");
            return false;
          else
            letters = letters + line;
        st = new StringTokenizer(taWords.getText(),"\n");
        words = new String[st.countTokens()];
        if(words.length > 0)
          for(int i = 0; i < words.length; i++)
            words[i] = st.nextToken();
        else
          JOptionPane.showMessageDialog(null,
            "no listing for words to find");
            return false;
        base = count;
        return true;
      private static void findTheWords()
        for(int i = 0; i < words.length; i++)
          int ii;
          for(ii = 0; ii < letters.length(); ii++)
            match = false;
            if(letters.substring(ii,ii+1).equals(words.substring(0,1)))
    checkNextLetter(ii,0,1,words[i]);
    if(match)break;
    if(ii == letters.length()) taWordsNewText += words[i]+" (not found)\n";
    taWords.setText(taWordsNewText);
    private static void checkNextLetter(int currentPos, int direction,
    int textPos,String wordToFind)
    if(direction == 0)
    int directions[] = {-(base+1),-base,-(base-1),-1,1,base-1,base,base+1};
    for(int x = 0; x < directions.length;x++)
    checkNextLetter(currentPos,directions[x],textPos,wordToFind);
    if(match) break;
    else
    int nextPos = currentPos + direction;
    if(letters.substring(currentPos,currentPos+1).equals(
    wordToFind.substring(textPos-1,textPos)))
    if(textPos == wordToFind.length())
    match = true;
    String startCoords = "("+(currentPos - (direction*
    (wordToFind.length()-1)))/base+","+(currentPos - (direction*
    (wordToFind.length()-1)))%base +")";
    String endCoords = "("+(currentPos/base)+","+(currentPos%base)+")";
    taWordsNewText += wordToFind+" "+startCoords+" - "+endCoords+"\n";
    return;
    else if(nextPos >= 0 && nextPos < Math.pow(base,2) &&
    Math.abs(currentPos%base - nextPos%base) <= 1)
    checkNextLetter(nextPos,direction,textPos+1,wordToFind);

  • 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
    }

  • Adding time char to infocube

    Hi,
    What precautions i need to take to replace a time char with another time chat  into a infocube and  infocube is in production.
    Thanks in advance
    krish
    Edited by: kris202729 on Dec 19, 2011 3:45 PM

    It's depend upon which Time Char. you are adding.
    1) I assume that 0CALDAY already in the flow and you are including 0CALMONTH which is mapped to 0CALDAY then there is no impact on production data.
    2) If 0CALMONTH already in the flow and you are including 0CALDAY then new data of 0CALDAY will come on date when you are included 0CALDAY production data.
    Regards,
    Sushant

  • 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

  • Adding new char in Bex global structure

    Hi all,
    I am trying to add a new char in already existing strucuture (of particular info-provider), how can I do that?
    when I right click on structure, it does not give me any options (but save as). if I use "save as" option, I have to save as new structure... I do not want to create new one...but just want to change and add some more fields/chars in old one.
    Thanks for you help,
    -sm

    ni

  • Adding individual cells from 3D array's pages to make one 2D array

    Hi everyone,
    Am a beginner, and have begun to like Labview. Especially because of great help available online (here) and other videos.
    Have managed to use all basic functionalities, but when I tried to add cell(i,j) across all k's (pages) of my 3D array, I am out of wits. 
    Tried Mathscript, but it doesn't handle 3D arrays. Eventually, Formula Node (C) came to rescue. Logic to do this is a no-brainer, but I don't know how to do it in Labview. Have tried things ranging from For loop, Insert into Array, Replace Array, Shift Register etc.
    If someone can answer this, I would be happy to get embarassed.
    Thanks

    Here's another possibility.
    Or this...
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SumOfPlanes.gif ‏3 KB
    SumOfPlanes2.gif ‏3 KB

  • Adding a pre-existing RAID5 array

    I'm running a solaris file server. I'm booting solaris off of a single disk and then have a RAID5 array across three disks for my data. I removed the disk that solaris was on, put in an empty hard drive and installed solaris again.
    My Question: How can I add my RAID5 array from my previous solaris install while keeping my data?

    Ok, so I ran metastat -p on the old install and got
    d0 -r c3d0s2 c1d0s2 c4d0s2 -k -i 32b
    Meaning that the name is d0, the disks it's on are
    c3d0s2 c1d0s2 c4d0s2 with an interlace size of 32b
    Assuing my disks are named the same thing on the new
    solaris install (they should be) I just feed that
    line there to metainit? As long as you have SVM configured on the machine, yes.
    Edit Final: Tried metainit, got the following
    metainit: pbfs01: there are no existing databasesThen you haven't set it up yet. You need to create metadevice replicas somewhere. They can be on the boot disk somewhere or on the array. It doesn't matter.
    The location of the old ones on the other machine would be shown by 'metadb'.
    If they were on the array, you can use the same location. When you do that, it will overwrite the old replicas.
    Once done, the 'metainit' command will work.
    Darren

  • Adding Free Char into report on Workbook

    Hi Friends
    How could we add a characteristic from free char list into query result on a workbook and how can we get filter button with free char list.
    Regards,
    Charan.

    Hi
    Thanks for the reply.
    How could we achieve by doing buttons.When we run the query then we can see filter button ,Info button.
    I want  to the same way on each sheet of the workbook.
    Regards,
    Charan.

  • Adding Simulate signal value to array

    This is my first VI.  I'm passing an array of 5 values which gets concatenated together into a string.  I thought it would be neat for the 5th value of the array to always be changing so I'm using the Simulate Signal VI.  I have the output from that VI working right but I'm not sure how to replace the 5th element.
    Thanks for your help
    Solved!
    Go to Solution.
    Attachments:
    sim signal.jpg ‏70 KB

    Hi Scott,
    I think you're fairly close to getting what you want! After you insert the signal into the array, you should wire the output of the Insert Into Array function into the Array to Spreadsheet String function. Right now it looks like you are just concatenating the array generated by your autoindexed for loop and ignoring the array you inserted the sine wave into.
    I hope this helps! Good luck!
    Regards
    Josh Y.
    Applications Engineer
    National Instruments

  • OutOfBoundsException with char array

    in the catch part how can i delete the last char in the array so it doesnt keep giving me the exception? Thanks for any help.
    try
         passWord[counter] = e.getKeyChar();
         counter++;
         System.out.print("*");     
    catch(ArrayIndexOutOfBoundsException b)
         System.out.println("Your passwords is too long, use back space to go back");
             //need statement to remove last char in the array
    }    

    i'll try it, thanks. But out of curiosity how would
    you delete using backspace?If you had to do it, it'd be quite a bit of work:
    1) is the input empty? if so ignore
    2) remove last char from input field and erase its view
    3) position the cursor at the correct position
    but lucky for you, you don't have to do that yourself, the JPasswordField
    does it all for you ;-)
    kind regards,
    Jos

  • Char array conversion from String: toCharArray()

    Greetings,
    Can anyone tell me why this code:
    import com.wuw.debug.Trace;
    public
    class charTest
       public static void
       main( String[] args )
           String strIn = new String( "strIn" );
           Trace.DTRACE( "strIn: "+strIn );
           Trace.DTRACE( "strOut: "+strIn.toCharArray() );
    }produces this output:
    [DTRACE]: strIn: strIn
    [DTRACE]: strOut: [C@1fef6f
    and not:
    [DTRACE]: strIn: strIn
    [DTRACE]: strOut: strIn

    Because:
    String.toCharArray returns an array of chars.
    An array is basically an object in java.
    Objects are converted to strings with the method toString - if it's not implemented in your class the string that method returns will be of the form classname@hashcode.
    In the case of a char array, the name of the class is "[C". The hashcode of you object seems to be "1fef6f" (in hex).
    You'll just have to remember that an array of chars is [i]not a string in java.

Maybe you are looking for

  • How to create multiple accounts on a back up USB HD?

    I have an external HD linked to my network via a Network USB Hub. I have two partitions: an NTFS for my XP machine and a Mac OS Extended partition for Mac back ups. I have three Mac books in the family. I would like to set up a separate account for e

  • CS5 Illustrator Multiple Glitches??

    Hi, first post so hello to all. I've been an Adobe user for 16 years and the new CS5 glitches are driving me mental. I'm getting the below issues and i'm hoping someone can offer some guidance to if it's a program problem? 1) Strokes seem to be snapp

  • SAP BW or BO ? Which is better and why

    Hi, I dont know much about SAP BW so I am not able to compare which one is better. It would be great if someone could help me comparing these tools. Which one is better and why ? If a user is already using SAP BW and planning to start using SAP BO wh

  • Depend a whole group to an item's value using an el expression JHS 10.1.3.2

    hi, i am using jdev 10.1.3.3 and jhs 10.1.3.2 versions. I'm trying to depend the updateability of a whole group to an item's value, in the group level property update allowed expression i write the following: #{bindings.PrjtetkapraitPoso.inputValue==

  • Aperture simply unusable on new iMac with Lion

    I bought a new iMac having been a happy user for many years (iMac 21.5" i3 3.06GHz with 4G RAM), and thought I'd upgrade to Aperture as I want to get a little more creative with my photos. I was astounded when I imported my iPhoto library of about 60