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
|
public class Tableur {
public static void main(String[] args) {
int c,e;
boolean retourVal;
String recherche, seek;
// Les variables du tableau sont déclarés et sont des String
String [][] tableau = {
{H,He},
{Li,Be,B,C,N,O,F,Ne},
{Na,Mg,Al,Si,P,S,Cl,Ar},
{K,Ca,Sc,Ti,V,Cr,Mn,Fe,Co,Ni,Cu,Zn,Ga,Ge,As,Se,Br,Kr},
{Rb,Sr,Y,Zr,Nb,Mo,Tc,Ru,Rh,Pd,Ag,Cd,In,Sn,Sb,Te,I,Xe}
};
recherche = JOptionPane.showInputDialog(null,"tapez un élément du tableau","Renseignement",JOptionPane.QUESTION_MESSAGE);
loop:
for (c = 0; c < tableau.length; c++) {
for (e = 0; e < tableau[c].length; e++) {
seek = tableau[c][e];
retourVal = seek.equals(recherche);
if (retourVal) {
break loop;
} else {
continue;
}
}
}
windows fen = new windows ();
} |
Partager