I am fairly new to java I have been working like mad at revamping this code and I feel like I am finally close to a good set up but I am getting this NullPointerException when I try to compile and execute. Any help would really be appreciated as I am stumped maybe my brain is just fried out on this at the moment I dont know.

I hope I posted this all right. The compiler is throwing back there error and it looks like this..........

Exception in thread "main" java.lang.NullPointerException
at Inventory.sortItems(Inventory6.java: 187)
at Inventory6.main(Inventory6.java:21)

That's way too much code to wade through, but the Exception is telling you what's wrong: on line 187, you're dereferencing a null Object. You can't do that. Make sure that all of your variables reference an instance of something before you use them.

April 13th, 2011, 09:56 AM

pyrotecc25

Re: NullPointerException error

Sorry about all the excess code I am new to posting in forums like this and wanted to ensure that I provided the right section of code. Thank-you for your reply though I do appreciate it very much.

April 13th, 2011, 12:00 PM

JJeng

Re: NullPointerException error

I've looked over it, but can't find it. At this point I'd put some println's in the sort method for cameraList[i] and i+1, as well as the value of i, above the if statement. I'd do it myself, but the workstation I'm at doesn't have a jdk installed :( , also is that a bubble sort? the variable name 'search' in the for loop is throwing me off.

jjeng ty I am looking at what you pointed out to see if I can figure it out.

junky are you referring to where I have the "newName" in the constructor?

April 14th, 2011, 01:46 AM

Junky

Re: NullPointerException error

Kaching!

The parameter is called newName and yet you pass name to the super constructor. Since name (which is an inherited variable from the parent class) is null all you do is reset name to be null.

April 14th, 2011, 01:17 PM

pyrotecc25

Re: NullPointerException error

Thank you Junky that was very helpful I appreciate the help very much. Now the only problem I am having is when I click my next and previous buttons and what not all the information in the boxes changes like its suppose to except the item name, for some reason it stays as sony. But again your assistance helped take a step in the right direction of getting this working right.