| ||||||||||
Question: One of the steps in the instructions suggests to change FrameSequence variable 'frames' to static. I changed this at the very top of the file under data storage section to read static frames;but when I try to compile, I get this error in line 4: Error: C:\CS1316\java-source-Fall06\WalkingSausageMan.java:4: <identifier> expectedAny idea what's wrong? Thanks I guess that didn't copy with the brackets, but the error says <_identifier_> expected (where the underscores are not present nor are spaces in Dr. Java error message. |
static FrameSequence framesDawn Finney
Question: In my renderScene, the first line (after the "public" line) is currently ColoringPicture pic = new ColoringPicture(name, t+2);When I try to compile it, I get the error: File: /Applications/DrJava/WalkingSausageMan.java [line: 15] Error: cannot find symbol symbol : constructor ColoringPicture(java.lang.String,int) location: class ColoringPictureThe same thing happens when I take the unmodified PurplePicture and try to run it. Any ideas? The ColoringPicture.java compiles and runs OK. |
ColoringPicture pic = new ColoringPicture(name, t+2);is attempting to call the constructor with two parameters. Instead, your call should be
ColoringPicture pic = new ColoringPicture(name);(where you must define your variable name before the call). Student1086
Question: I am getting a NullPointerException error every time I try to run my code and it forces me to restart Dr. Java. What could be causing this? |
String testString = null; System.out.println(testString.toString()); //NullPointerException occurs hereThe problem here is that I am calling a method on an Object that is null. null is essentially a placeholder for an actual Object and is not capable of any actions. So when you call a method on testString who is null, it just goes "Nope. Can't do that" and throws the exception.
String testString = null; System.out.println(testString); System.out.println(testString.toString());Another similar example:
int[]array = null; for(int i = 0; i < array.length; i++) //NullPointerException occurs here System.out.println(array[i]);Using my method for testing/debugging, the above code would be:
int[]array = null; System.out.println(array); for(int i = 0; i < array.length; i++) //NullPointerException occurs here System.out.println(array[i]);It is important to note in this case that we are not trying to call a method on the Object but will still yield a NullPointerException
Question: I am trying to use custom colors in my code, but some colors don't seem to work. For instance, new Color(50,0,50)turns out black rather than dark purple, and new Color(250,100,0)comes out red instead of orange. Is there a predefined color table that Java is automatically snapping my colors to? |