Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9118349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:07:58+00:00 2026-06-17T05:07:58+00:00

I’m using Processing 2.0b7. I have a Spool class that is supposed to have

  • 0

I’m using Processing 2.0b7. I have a Spool class that is supposed to have an ArrayList of Note objects in it. In Spool’s draw method, I want to call each Note in the ArrayList’s draw method. However, when I try do that with this syntax, I get the error “

Exception in thread “Animation Thread” java.lang.NullPointerException
at spoolloops$Spool.draw(spoolloops.java:119) at
spoolloops.draw(spoolloops.java:39) at
processing.core.PApplet.handleDraw(PApplet.java:2142) at
processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:193)
at processing.core.PApplet.run(PApplet.java:2020) at
java.lang.Thread.run(Thread.java:662)

PLEASE NOTE This is the Processing environment, which runs some sort of Java, but is different in important respects. I know the syntax is very different, because you don’t have to declare scope or return types for methods in classes. But since I’m not a Java export, I don’t know the exact hows and whyfors of the differences.

If you want to give an answer, please make sure that it will work in processing and not just Java. I’m pretty sure that this code will throw all kinds of errors in a pure Java environment, but that’s not what it’s running in, so it doesn’t matter. The platform is Processing.

class Spool {

  int diameter = 50;
  int i, angle;
  Note note, test;

  ArrayList<Note> notes;

  void Spool() {
    notes = new ArrayList<Note>();
    notes.add( note = new Note(100.0,100.0,100.0,100.0,100.0) );
    notes.add( note = new Note(120.0,120.0,120.0,120.0,120.0) );
  }

  void draw() {    
    for (int i = 0; i < notes.size(); i++) {
      test = (Note)notes.get(i);
      test.draw();

    }

    angle = angle + 1;
    if ( angle > 360 ) {
      angle = 0;
    }

  }
}

class Note {

  float diameter, x,y, start, stop;

  Note(float Diameter, float X, float Y, float Start, float Stop) {
    diameter = Diameter;
    x = X;
    y = Y;
    start = Start;
    stop = Stop;
  }

  void turn(float degrees) {
  }

  void draw() {
    strokeWeight(25);
    arc( x,y,diameter, diameter, radians(start), radians(stop));
  }
}

The notes.size() in the for loop is what seems to cause the problem, but when I change it to i < 1, the error occurs at test = (Note)notes.get(i);. I suppose the ArrayList is not properly getting filled with Note Objects?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:08:01+00:00Added an answer on June 17, 2026 at 5:08 am

    Class and Object Initializers do not return a type. Remove the “void” from

    void Spool()
    

    leave it as

    Spool()
    

    Otherwise it is not called during creation.

    Also it’s not totally necessary to have the

    notes.add( note = new Note(100.0,100.0,100.0,100.0,100.0) );
    

    It is my understanding that it can simply be:

    notes.add(new Note(100.0,100.0,100.0,100.0,100.0) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am using JSon response to parse title,date content and thumbnail images and place
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.