Bonjour , je viens de commencer le java et je galère depuis 2h sur ce problème , tout d'abords mon 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
 
/*Blabla 
Blabla*/ 
class TP43 { 
final int N=15; 
 
void principal() { 
 
int[]Tab=new int[N]; 
int nbElem; 
int position; 
int elemajout; 
 
remplir(Tab,nbElem); 
 
afficherTAB(Tab,nbElem); 
 
while ( nbElem<N ) { 
 
inserer(Tab,nbElem,position,elemajout); 
 
}
 
afficherTAB(Tab,nbElem);  
}
 
/*----------------------------------------------------------------------------------------*/   
 
 
void remplir(int[]leTab,int nbElem) { 
 
int i;
 
nbElem=SimpleInput.getInt("Combien d'éléments nbElem voulez-vous ?"); 
 
if( (nbElem<0)||(nbElem>N) ) 
			{ System.out.println("Ce n'est pas possible , 0<nbElem<N"); } 
		else { 
				for(i=0;i<nbElem-1;i++) { 
				leTab[i]=SimpleInput.getInt("Entrez un entier."); 
				} 
			} return;
		}
 
 
/*----------------------------------------------------------------------------------------*/  
 
 
void inserer(int[]unTab,int nbElem,int position,int elemajout) { 
 
int i; 
 
position=SimpleInput.getInt("Position de l'éléments à ajouter ?"); 
 
if( (position<0)||(position>=nbElem) ) 
			{ System.out.println("Impossible 0<=position<nbElem"); } 
		else { 
				elemajout=SimpleInput.getInt("Element ( entier ) à ajouter ? : "); 
				for(i=nbElem-1;i>position;i=i-1) { 
				unTab[i+1]=unTab[i]; 
				} 
				unTab[position]=elemajout; 
				nbElem=nbElem+1; 
				} return;
				}
 
 
void afficherTAB(int[]duTab,int nbElem) { 
 
int i; 
 
System.out.println("Voici le contenu du Tableau");
 
			for(i=0;i<nbElem-1;i++) { 
			System.out.println(duTab[i]);
 
} return; }
 
}
Et on m'indique comme erreur :

Variable position , nbElem et elemajout "might not have been initialized".


Une idée ?

Merci d'avance je commence à déprimmer sévère