|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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) |
|
#2
|
|||
|
|||
|
help
i also geting this problem plz any one help
|
|
#3
|
|||
|
|||
|
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? |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > Problem Object with array |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|