unexpected token: void
in
Programming Questions
•
11 months ago
Hey guys, im trying to write a program which will draw an ellipse for some data I have in arrays, but when I execute it it gives me the error: unexpected token: void
Its referring to the void in the void draw() section, but I don't know why
- //Declare an array to hold each line of the data file
- String[] lines;
- //Delcare an array to hold each one of the unique street types
- //and initially add just a single, empty value " "
- String[] streetTypes = {
- " "
- };
- int[] streetcounts = {
- 77, 474, 36, 1, 1, 13, 159, 140, 1, 18, 1, 1, 109, 9, 3, 4, 126, 3, 36, 82, 1, 996, 1, 2, 71, 2, 4, 144
- };
- void setup() {
- size(500, 500);
- background(90, 220, 225);
- stroke(255, 0, 0);
- //Load data
- lines = loadStrings("Street_Names2.csv");
- //Loop through once for each line in the data file
- for (int i = 0; i < lines.length; i++) {
- //Split line into pieces
- String[] pieces = split(lines[i], ',');
- //
- // COUNT ALL STREET TYPES
- //
- //Look at whatever type of street this street is
- String thisStreetType = pieces[1];
- //Is this street type new to us? Assume it is for now.
- boolean isThisNew = true;
- //Loop through ALL of the streetTypes, and see if this street type is already recorded (or not)
- for (int j = 0; j < streetTypes.length; j++) {
- //If the types match, then this isn't a new type after all
- if (thisStreetType.equals(streetTypes[j])) {
- isThisNew = false; //...so set isThisNew to false
- }
- }
- //If we *still* think this is a new street type...
- if (isThisNew) {
- streetTypes = append(streetTypes, thisStreetType); //...then append it to the big array
- }
- }
- //Finally, remove the first empty item in the array, now that it's no longer needed
- streetTypes = subset(streetTypes, 1);
- //Print out the final array of streetTypes to the console
- println(streetTypes);
- //Draw a dot for each row of data
- void draw() {
- for (int i = 0; i < streetTypes.length;) {
- smooth();
- stroke(255);
- fill(255, 255, 255, 90);
- ellipse(0, 0, streetcounts[i], streetcounts[i]);
- }
- }
1