title: array index out of bound for append array result into java text area
body: <p>I have two program which are SocketServer and MyNoteCenter. Every time the user click the download button,it will send to the SocketServer for storing. The user can retrieve their record by click the show button to show the record. After that, append to the text area but unfortunately I get an ArrayOutOfBound error for my code. The errors show me that the display method in MyNoteCenter and show method in SocketServer method. I had search a lot of solution on my problem but it still look the same and I checked the array index was enough to hold 5 data. The 5 data will bring to the SocketServer by using the parameter constructor when certain function being invoke at MyNoteCenter </p>
  
  <p>MyNoteCenter program(portion)</p>
  
  <pre><code>  if(e.getSource()==btn3)
      {
          String  [] ds = new String[5];
          ds = display();
          for(int i = 0; i &lt;=ds.length;i++)
           {
              ta1.append("Result"+i+":"+ds[i]);
           }
      }
      public String[] display()
         {
           SocketServer ds = new SocketServer();
           String [] STRarr = new String[5];
           STRarr[5] = ds.show();
           return STRarr;
         }
  </code></pre>
  
  <p>SocketServer program(portion)</p>
  
  <pre><code>public SocketServer(String selection,String id,String name,String year,String major) //The constructor accept the value from user and store it, it's being implement at others function  
  {
   this.selection = selection;
   this.name = name;  
   this.id = id ;
   this.year = year ;
   this.major = major ;
  }
  public String show()
  {
      String [] arr = new String[5];
      arr[0] = name;
      arr[1] = id;
      arr[2] = year;
      arr[3] = major;
      arr[4] = selection;
      counter++;
      JOptionPane.showMessageDialog(null,"You are in" +counter);
      return arr[5];
  
  }
  </code></pre>