Another thing: if you are using that code for an interview, you will have problems. For example the pack() method is too long. For another, you probably shouldn't use com.packer as a package name. That package name belongs to somebody else, as you will find out if you go through the Java™ Tutorials.
If you are using a Scanner to read lines from the file, why are you then using String#split and String#trim? Wouldn't it be better to create a regex which strips the whitespace, too? Or use a second Scanner?
Why does the Packer class have all static methods?
What does line 28 mean? Why have you got a capital W?
What does all the commented‑out code mean?
Why is the text file in that particular location on your disc?
Stephan is, I think ahead of me. I fail to understand what you mean about adding the contents rather than memory locations in the List. What did you expect the List to contain? The whole idea of object‑orientation is that you retain the information in the object, so the contents of the String live in the String object. Why would you expect the List to contain the contents of the String object rather than a reference to the object?
This constructor. Probably not the constructor itself but its parameters. In particular second and third. I think they are very very confusing because of presence of them two in the same place.
Third parameter I'd expect to be "items". Second, probably "itemsCount", in fact - you don't need probably that second if indeed it represents items count, because you could get that by issueing "itemList.size()".
By the way, parameter "weight", why is it an int? Is it in grams?
Also, you got weird indentation, I've never seen it before. Package statement supposed to be aligned with import statements.
Another thing, you got quite a few static methods in class 1 (Packer). It might makes sense to have them static or might not, but why they are in the class Packer? What method removeParenthesis has to do with Packer class?
Then, you have method "pack" where you're passing in file path, so what are you packing? Isn't it confusing? Non descriptive?
I'd expect you to open file, which is in the path... but not pack it. Method names supposed to make sense, so everybody reading could understand what your program does. As a proof you can see that Campbell failed to understand, it suggests that program is confusing.
I'd suggest you to keep structure like:
Now, if you follow that advice, you'll get procedural code, but from that you'd have more chances to make it object oriented. Give a try if you willing to and see if you like it more than what you have now.
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad: