Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 28th, 2008, 06:37 AM
Supura Supura is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 3 Supura User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 33 sec
Reputation Power: 0
Problem Object with array

hi all
I have a problem with my object
i send array in object and its return me
this msg error :

Code:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
        at masteracobjet.Mastermind.prop(Mastermind.java:83)
        at masteracobjet.Main.main(Main.java:48)
Java Result: 1



in my object in the method :

Code:
public void proposi(int [][] inProposi,int n,int nbP)
{
      
  int[][] prop = new int[n][nbP+2];

}


thanx for your help

Last edited by Supura : March 4th, 2008 at 08:42 AM. Reason: formatage (code tags)

Reply With Quote
  #2  
Old March 3rd, 2008, 12:55 AM
salmanumar007 salmanumar007 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Location: london
Posts: 1 salmanumar007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 14 m 26 sec
Reputation Power: 0
Send a message via AIM to salmanumar007 Send a message via MSN to salmanumar007 Send a message via Yahoo to salmanumar007
MySpace
help

i also geting this problem plz any one help

Reply With Quote
  #3  
Old March 4th, 2008, 03:14 PM
paulscode paulscode is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Location: Fort Meade, MD
Posts: 35 paulscode User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 56 sec
Reputation Power: 1
There doesn't appear to be anything wrong with the code you posted here. It complied and ran fine with no exceptions when I used your class, and then created a new "proposi" like this:
Code:
proposi myProposi = new proposi( new int[1][2], 3, 4);

Judging from the error you are getting, I suspect the problem is in how you are accessing your proposi after creating it. It could be something like a zero-based issue. If you haven't solved this problem yet, could you post the code you are using to access your object?

Reply With Quote
  #4  
Old March 5th, 2008, 03:20 AM
Supura Supura is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 3 Supura User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 33 sec
Reputation Power: 0
Code:
    int  [][]  TabP=new int[nbE][nbP];
    
    String resu="";
//////////////////////////////////////////////////////////////////
    
    Mastermind Master=new Mastermind();
   
    Master.couleur(nbC);
    Master.essai(nbE);
    Master.taille(nbP);
    Master.soluce(nbC, nbP);    
    Master.marke(tabMarkeur);
    Master.proposi(TabP[][],nbE,nbP);


this is the part in my MAIN to access to Proposi for give the sizes of the array

thanks for your help

Reply With Quote
  #5  
Old March 5th, 2008, 08:01 PM
paulscode paulscode is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Location: Fort Meade, MD
Posts: 35 paulscode User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 56 sec
Reputation Power: 1
The problem is a syntax error in the line:
Code:
Master.proposi(TabP[][],nbE,nbP);

Depending on what you are trying to do here, I think you want this line to be:
Code:
Master.proposi(TabP, nbE, nbP);

Also, if you look at the "proposi" method, all it does is create a new int[][] called "prop", and then it exits without doing anything (it disregards "prop" without using it).

What do you want the "proposi" method to actually do?

For example, IF you want it to change the int[][] you are passing to it, then it should look like this:
Code:
    public proposi( int [][] inProposi,int n,int nbP )
    {
        int[][] prop = new int[n][nbP+2];
        inProposi = prop;
    }

It all just depends on what want that method to actually do.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Problem Object with array


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway