String from an array to int. NullPointerExeption
in
Programming Questions
•
6 months ago
I have a file with a list of numbers I need to add. I load it using loadStrings(), and then I want to convert each line of String array to an int. I wonder why I get a NullPointerExeption error?
- String lines[] = loadStrings("nums.txt");
- int sum;
- int converted;
- int i = 1;
- void draw() {
- if (i<100) {
- sum=sum+int(lines[i]);
- println(sum);
- i++;
- }
- }
1