This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
This is not the whole program. But basically the program takes a <path> tag (or multiple path tags) from a scalable vector graphic file and converts it to a string and then removes n% unimportant points that the user decides.
Thanks to all those who can help!
This is the error that I am receiving when I go to test my code with an actual SVG file:
I did some research and found that this error is caused by probably one of these three:
- Attempting to invoke an instance method of a null object
- Attempting to access or modify a particular field of a null object
- Attempting to obtain the length of such null object as an array
I have failed to locate the problem. Any suggestions on where in this code I can look for the problem and possibly a hint on what the specific problem is?
Here is a code snippet that ends on line 54 of my SVG.java file
William Koch wrote:If Paths is null why can I not add something to it.
Because it's null. The Paths variable holds a reference whose value is null--that is, a reference that doesn't point to any object. You have to create your ArrayList object before you can call methods on it. You can't call methods on a null reference.
I declared Paths in line 6.
Declaring a variable != creating an object.
Is there a simple fix?
Do I need to give Paths some initial value?
You have to give it a non-null value before you dereference it. The most appropriate place in this case is probably the line where you declare it, but it doesn't have to be there.
I am new to Java if you haven't noticed. My first language was Ada95 but now I am having to learn Java as they try to teach me data structures. I am in my second programming course for my undergrad in Computer Science (it is a Data Structures course).
I appreciate all the help you give here at The Ranch