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;
}
}
I tried to use an integer array(cypher) to hold an integer array(guess) after coming out of a function(encryption). However, this program doesn't work.The below notifications came out.
Exception in thread "main" java.lang.NullPointerException
at test.encryption(test.java:31)
at test.main(test.java:19)
Why? how can i correct it?
Thank you guys