Bonjour, j'ai un souci lors d'un exercice en java, il faut créer dans une classe TableauInt décrite ci-dessous une méthode boolean egal(TableauInt t) qui test si l'objet a les mêmes entiers aux mêmes places que le tableau t passé en paramètre. Voici mon code(la méthode en question est en bas du code):

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
public class TableauInt{
    int tab[]=new int[10];
 
    TableauInt(){
	for(int i=0; i<tab.length;i++)
	    tab[i]=(int)(Math.random()*100);
    }
    TableauInt(int n){
	for(int x=0; x<tab.length;x++)
	    tab[x]=n+x;
    }
    public String toString(){
	String s="["+tab[0];
	for(int x=1; x<tab.length;x++)
	    s=s+","+tab[x];
	s=s+"]";
	return s;
    }
 
    public int rangMax(){
	return tab.length-1;
    }
 
    public int somme(){
	int somme=0;
	for(int x=0; x<tab.length; x++)
	    somme+=tab[x];
	return somme;
    }
 
 
//Voilà la méthode en question:
    public boolean egal(TableauInt t){
	boolean test=true;
	for(int y=0; y<tab.length; y++)
	    if(t[y]!=tab[y]) test=false;
	return test;
    }
 
}
Lors de la compilation, j'obtiens ça:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
TableauInt.java:34: array required, but TableauInt found
	    if(t[y]!=tab[y]) test=false;
	        ^
1 error
Je débute avec les tableaux et je ne vois pas trop où est le problème, surtout que je crois qu'on est pas censé utiliser les array à ce stade donc voilà, si quelqu'un saurait pourquoi ma méthode ne marche pas je lui en serai reconnaissant!