Bonjour , j'ai un petit souci pour lire un byte et initiliser min tableau de byte .

Voici le code pour lire le Byte
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
private static void printPrompt(String prompt)
  {  
  	System.out.print(prompt + " ");
	   System.out.flush();
  }  
  /**
        *  Affiche le message prompt, saisit et retourne un byte  
        */	
  public static byte readByte(String prompt)
  {  while(true)
	  {  printPrompt(prompt);
		 try
		 {  return Byte.valueOf
			   (readString().trim()).byteValue();
		 } catch(NumberFormatException e)
		 {  System.out.println
		 ("ce n'est pas un byte. Essayez de nouveau !");
		 }
	  }
  }
et voici ou j'appéle la méthode readByte dans ma méthode init():

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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
public class Registre {
 
	private int taille ;
	private byte [] tab ;
 
	/**
         * Constructeur Vide
         */
	public Registre (){
 
	}
 
	public Registre(int taille){
 
		this.taille = taille ;
	}
	/**
         * 
         * @param tab
         */
	public Registre(byte[] tab){
 
		this.tab = tab ;
	}
	/**
         * 
         * @param r
         */
	public Registre(Registre r){
 
		this.taille = r.taille ;
		this.tab = r.tab ;
	}
 
	public Registre and (Registre r ){
 
		Registre r_res = new Registre();
 
		for(int i = 0; i < tab.length ; i++){
 
 
			if ( (this.tab[i]== 0 && r.tab[i]==0 ) || (this.tab[i]== 0 && r.tab[i] == 1) ||
					(this.tab[i]== 1 && r.tab[i] == 0)  ){
 
				  r_res.tab[i] = 0;
 
			}
			else
				r_res.tab[i] = 1;
		}
 
		return r_res ;
 
 
	}
 
	public void decaleDroite(){
 
		byte y = this.tab[tab.length];
 
		for(int i = 0; i <tab.length -1 ; i++){
 
			this.tab[i + 1] = this.tab[i];
 
		}
		this.tab[0]= y ;
 
 
	}
 
	public void decaleGauche(){
 
		byte x = this.tab[0];
 
		for(int i = 0; i <tab.length -1 ; i++){
 
			this.tab[i ] = this.tab[i+1];
 
		}
		this.tab[0]= x ;
 
	}
	public void init(){
 
		System.out.println("Initialiser le registre courant !");
		this.taille = Clavier.readInt("entrer la taille du registre");
		System.out.println("initialiser le registre");
 
		for(int i =0; i< taille ; i++){
 
 
			this.tab[i] = Clavier.readByte("valeur num :" + i);
			System.out.println();
		}
 
 
	}
 
	/*
	public int[] getTab(){
 
 
	}
 
 
	public Registre ou (Registre r){
 
 
	}
 
	public int registreToDec(){
 
 
	}
 
	public String registreToHexa(){
 
 
	}
 
	public void setTab(byte []t){
 
 
	}
	public int tailleRegistre(){
 
 
	}
	*/
	public String toString(){
 
		String s ; 
 
		s = "le registre est : " + this.tab +" et sa taille et de "+ this.taille;
 
		return  s ;
 
 
	}
 
}
et quand je test mon init dans un programme de test
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
Registre r1 = new Registre();
		System.out.println("initialisation") ;
		r1.init();

: voila ce que j'ai comme message d'erreur :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
Exception in thread "main" java.lang.NullPointerException
	at Registre.init(Registre.java:100)
	at TestRegistre.main(TestRegistre.java:8)
Je n'arrive pas à rentrer des valeur byte ! je sais qu'il y a qqch que j'ai ratté mais je ne sais pas quoi. Est ce que qqun a une idée la dessus ?