Ah yes, I think I know why.
Try changing it to:
Code: // Import the source file: list.txt
String[] lines;
// Create array that will contain the length, in number characters, for each line
int[] longs;
void setup() {
size(1000,500);
lines = loadStrings("list.txt");
longs = new int[lines.length];
smooth();
background(50);
// Fill length array, "longs," with values from the "lines" array
for(int i = 0; i < lines.length; i++) {
String a = lines[ i];
int x = a.length();
longs[ i] = x;
}
}
void draw() {
// Print the number of lines
println("There are " + lines.length + " lines!");
// Create a randomly placed and colored circle for each line, size of circle proportional to line length
noStroke();
for (int i = 0; i < lines.length; i++) {
int b = longs[ i];
fill(random(0,255), random(0,255), random(0,255), random(0,255));
ellipse(random(100,width-100), random(100,height-100), b/4, b/4);
}
}
The problem is that even though the line to load the strings is before the longs definition, the loadStrings can't happen until the program actually runs, and the compiler has to create memory for the longs and lines arrays at compile-time, which it can't do, as it doesn't know how long list.txt is.
Basicly, if you'r using the setup/draw style of sketch, it's better if you don't give values to variables outside of a function, as you can't guarantee that it'll work as expected. You can define them outside, and need to in many cases, you just need to wait until inside setup() to actually give them a value/values.