Getting NPE while using getChars method.
Code
public class GetCharsDemo {
public static void main(String[] args) {
String temp = "Some string!";
int from = 5;
int to = 9;
char[] store = null;
temp.getChars(from, to, store, 1);
System.out.println("Character array - " + store[0]
+ store[1] + store[2] + store[3]);
//System.out.println(temp.substring(from));
}
Output -
Exception in thread "main" java.lang.NullPointerException
at java.lang.System.arraycopy(Native Method)
at java.lang.String.getChars(Unknown Source)
at com.dataTypes.GetCharsDemo.main(GetCharsDemo.java:11)
Values should store to char array named store.
Please help here.