Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 whatdotcolor
Index -> Programming, Java -> Java Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
GoVikingsGo




PostPosted: Tue Jan 17, 2006 10:57 pm   Post subject: (No subject)

i know i might be overlookings something cause im tired but i get an ArrayOutofBoundsException on the

my array is a 2d memVar [7][6]

code:

else if (memVar [col] [6] == 1)


code:

// Redraws the tokens
            for (int col = 1 ; col < 7 ; col++)
            {
                if (memVar [col] [1] == 1)
                {
                    c.setColor (Color.red);
                    c.fillOval (25, 120, 50, 50);
                }
                else if (memVar [col] [2] == 1)
                {
                    c.setColor (Color.red);
                    c.fillOval (25, 182, 50, 50);
                }
                else if (memVar [col] [3] == 1)
                {
                    c.setColor (Color.red);
                    c.fillOval (25, 244, 50, 50);
                }
                else if (memVar [col] [4] == 1)
                {
                    c.setColor (Color.red);
                    c.fillOval (25, 306, 50, 50);
                }
                else if (memVar [col] [5] == 1)
                {
                    c.setColor (Color.red);
                    c.fillOval (25, 368, 50, 50);
                }
                else if (memVar [col] [6] == 1)
                {
                    c.setColor (Color.red);
                    c.fillOval (25, 430, 50, 50);
                }
                else if (memVar [col] [1] == 2)
                {
                    c.setColor (Color.blue);
                    c.fillOval (25, 120, 50, 50);
                }
                else if (memVar [col] [2] == 2)
                {
                    c.setColor (Color.blue);
                    c.fillOval (25, 182, 50, 50);
                }
                else if (memVar [col] [3] == 2)
                {
                    c.setColor (Color.blue);
                    c.fillOval (25, 244, 50, 50);
                }
                else if (memVar [col] [4] == 2)
                {
                    c.setColor (Color.blue);
                    c.fillOval (25, 306, 50, 50);
                }
                else if (memVar [col] [5] == 2)
                {
                    c.setColor (Color.blue);
                    c.fillOval (25, 368, 50, 50);
                }
                else if (memVar [col] [6] == 2)
                {
                    c.setColor (Color.blue);
                    c.fillOval (25, 430, 50, 50);
                }
            }




thanks alot
Sponsor
Sponsor
Sponsor
sponsor
evogre3n




PostPosted: Tue Jan 17, 2006 11:20 pm   Post subject: (No subject)

try catchs are your friend Very Happy
evogre3n




PostPosted: Tue Jan 17, 2006 11:23 pm   Post subject: (No subject)

GoVikingsGo wrote:

else if (memVar [col] [6] == 1)


You'll notice that your array
is [7][6]

which means the array has locations 0,1,2,3,4,5 (6 total locations)

setting the if statement to 6 would give you out of bounds exception...
GoVikingsGo




PostPosted: Wed Jan 18, 2006 8:15 am   Post subject: (No subject)

6 and 7 thats the 42 position
GoVikingsGo




PostPosted: Wed Jan 18, 2006 10:08 am   Post subject: (No subject)

cancel last thx
GoVikingsGo




PostPosted: Thu Jan 19, 2006 5:05 pm   Post subject: (No subject)

new problem does any1 know how to use the time class so that i can do

code:

c.println ("The time is " + ?????????);


Please help ASAP thanks[/code]
Hikaru79




PostPosted: Fri Jan 20, 2006 12:21 am   Post subject: (No subject)

GoVikingsGo wrote:
new problem does any1 know how to use the time class so that i can do

code:

c.println ("The time is " + ?????????);


Please help ASAP thanks[/code]


http://java.sun.com/j2se/1.4.2/docs/api/java/util/GregorianCalendar.html
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 22 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: