I think what you are doing is mistaking a method for a constructor or
vice versa. You have a method called public void inventory, which does three things. That is not a good idea; a method should do one thing.
It does these three things
Set up the contents of the inventory.Calculate the total value of each line.Print the details.
You ought to have the setting-up done in a constructor, but not the other two things. A constructor can be identified by
Having a name exactly the same as the name of the class (including CaSe Of LeTtErS).Having no return type.
You should work out the inventory values when you request them. It would appear that you need a getInventoryValues method which works out all the inventory values and returns them as a double[]. Yes, you return a reference to an array.
Then you should organise a print() method, preferably in conjunction with a
toString() method. Like this
And good luck and welcome to JavaRanch
And please don't write "Java help" as a
thread title.