0
import java.util.*;
public class test
{
public static void main(String[] args)
{
Scanner Input = new Scanner(System.in);
int[] guess;
guess = new int[6];
for(int i =0 ; i<5;i++)
{
guess[i] = Input.nextInt();
}
**int[] cypher = encryption(guess);**
System.out.print(cypher);
}
public static int[] encryption(int[] guess)
{
int[] cypher = null;
int end = guess.length;
for(int i=0 ; i< end ; i++)
{
**cypher[i] = guess[i] + 1;**
}
return cypher;
}
}
関数(暗号化)から出た後に整数配列(推測)を保持するために整数配列(cypher)を使用しようとしました。しかし、このプログラムは動作しません。以下の通知が出ました。Java暗号化と配列のエラー
Exception in thread "main" java.lang.NullPointerException
at test.encryption(test.java:31)
at test.main(test.java:19)
なぜですか?どうすれば修正できますか?
あなたCYPHER配列がnullの男