Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 该程序没有';t“中的输入”;如果;_Java_If Statement_For Loop - Fatal编程技术网

Java 该程序没有';t“中的输入”;如果;

Java 该程序没有';t“中的输入”;如果;,java,if-statement,for-loop,Java,If Statement,For Loop,有人能帮我吗? 对不起,我的英语不好。伙计,你不能在Java中这样使用=!操作员检查两个对象是否指向同一内存引用。。。您必须使用:if(aMex[i].equals(alfabeto[j])和Java字符串,记住==运算符测试,如果引用相同 .equals()测试值是否相同 所以在您的情况下,您应该使用.equals来测试值相等。 请在此查看全面信息 public class cripto { static String chiave, mex; static int lu

有人能帮我吗?
对不起,我的英语不好。

伙计,你不能在Java中这样使用
=
!操作员检查两个对象是否指向同一内存引用。。。您必须使用:
if(aMex[i].equals(alfabeto[j])

和Java字符串,记住==运算符测试,如果引用相同 .equals()测试值是否相同

所以在您的情况下,您应该使用.equals来测试值相等。 请在此查看全面信息

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");
    }
}
                if(aMex[i]==alfabeto[j]){
                    aCripto[i]=aChiave[j];
                }