Results 1 to 3 of 3
  1. #1
    Gregadeaux is offline Member
    Join Date
    Dec 2009
    Posts
    5
    Rep Power
    0

    Default Can't Solve Array Error

    Ok so i keep getting a "Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException:" error.

    This is for a chat program. The error is in the sendAll(String S) method:

    PHP Code:
    package chatServer;
    
    import java.util.ArrayList;
    import java.io.PrintWriter;
    
    /**
     *
     * @author Greg
     */
    public class OutputManager
    {
        private ArrayList<PrintWriter> out = null;
        private int x = 1;
        private PrintWriter sendTo = null;
    
        public OutputManager()
        {
            out = new ArrayList<PrintWriter>();
        }
    
        public void addOut(PrintWriter o)
        {
            out.ensureCapacity(x+1);
            out.add(o);
            x++;
        }
        
        public void sendAll(String s)
        {
            for(int y = 0; y <= out.size(); y++)
            {
                sendTo = out.get(y);
                sendTo.println(s);
            }
        }
        
        public void sendOne(String s, int pos)
        {
            out.get(pos).println(s);
        }
    }
    Any help would be great. This, right now, is the only thing giving me errors.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    Gregadeaux is offline Member
    Join Date
    Dec 2009
    Posts
    5
    Rep Power
    0

Similar Threads

  1. How to solve this "Fixtures code" error exception?
    By makerror in forum New To Java
    Replies: 4
    Last Post: 12-02-2009, 02:45 AM
  2. how to solve syntax error
    By pro85 in forum Java Applets
    Replies: 5
    Last Post: 04-06-2009, 11:20 AM
  3. Can't solve error message while looping
    By BHCluster in forum New To Java
    Replies: 15
    Last Post: 04-22-2008, 10:51 AM
  4. How to solve "No compiler error"?
    By iceman in forum New To Java
    Replies: 5
    Last Post: 04-22-2008, 03:37 AM
  5. Help mi solve my error
    By Deon in forum New To Java
    Replies: 3
    Last Post: 01-11-2008, 05:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •