integers from array
in
Programming Questions
•
6 months ago
hi,
i have a text file with a range of numbers in it.
i want to read the file and load the contents to an array. the display one random number on the screen from the array.
i wrote a piece of code, but every time im outputting the anwser im getting ' [L]Java.lang.String ..." instead of a number.
i know i can use the random keyword in processing to a get a random number. but i want it to read from a text file.
im doing something wrong - any help please?
below is my code ...
void setup() {
size (500, 500);
int[] data;
String[] numbers = loadStrings ("numbers.txt");
data = int(numbers);
int x = data[0];
text(""+numbers, 100,100,100,100);
}
void draw () {
text("Progress",20, 200, 150, 20);
for(int i =1; i < 2; i++) {
rect(100*i,200, 150, 20*i);
//rect(20*i,20,20,20*i);
}
}
1