why am i getting a null pointer when converting string to int array?
        Posted  
        
            by 
                Sackling
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Sackling
        
        
        
        Published on 2012-03-22T17:19:38Z
        Indexed on 
            2012/03/22
            17:30 UTC
        
        
        Read the original article
        Hit count: 275
        
java
My main method:
public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    String string1;
    string1 = input.next();
    LargeInteger firstInt = new LargeInteger(string1);
    System.out.printf("First integer: %s \n", firstInt.display());
}
LargeInteger class:
public class LargeInteger {
    private int[] intArray;
    //convert the strings to array
    public LargeInteger(String s) {
        for (int i = 0; i < s.length(); i++) {
            intArray[i] = Character.digit(s.charAt(i), 10); // in base 10
        }
    }
    //display the strings
    public String display() {
        String result = "";
        for (int i = 0; i < intArray.length; i++) {
            result += intArray[i];
        }
        return result.toString();
    }
}
© Stack Overflow or respective owner