public class cripto {
static String chiave, mex;
static int lungC,lungM, lungAl,lungCh;
static String[] aChiave, aMex;
static String[] alfabeto = {"a", "b", "c","d", "e", "f","g", "h", "i","l", "m", "n","o", "p", "q","r", "s", "t","u", "v", "z"};
public static void main(String[] args) {
// TODO Auto-generated method stub
chiave=JOptionPane.showInputDialog(null, "Inserisci chiave di criptografia di lunghezza: "+alfabeto.length);
System.out.println("chiave: "+chiave);
lungC=chiave.length();
for (int i=0; i<lungC; i++){
aChiave=chiave.split("");
System.out.println(i+": "+aChiave[i]);
}
mex=JOptionPane.showInputDialog(null, "Inserisci messaggio");
System.out.println("messaggio: "+mex);
lungM=mex.length();
for (int i=0; i<lungM; i++){
aMex=mex.split("");
System.out.println(i+": "+aMex[i]);
}
lungAl=alfabeto.length;
lungCh=aChiave.length;
System.out.println("Lunghezza array alfabeto: "+lungAl);
System.out.println("Lunghezza array chiave: "+lungCh);
String[] aCripto=new String[lungM];
if(aChiave.length==alfabeto.length){
for(int i=0;i<lungM;i++){
for(int j=0;j<alfabeto.length;j++){
//System.out.println(i+": "+h+" - "+h1);
if(aMex[i]==alfabeto[j]){
aCripto[i]=aChiave[j];
}
}
}
}else{
JOptionPane.showMessageDialog(null, "Lunghezze diverse");
}
}
}
Hy guys, I Made this simple criptography's program but I have the problem that in the for, the program doesn't enter in the "if" even if the equality is verified.
if(aMex[i]==alfabeto[j]){
aCripto[i]=aChiave[j];
}
can someone help me? sorry for my bad english.