I made a slight change to the data and the order of the sorts and now none of them work.
public static void main(String [] args) {
hardware.add( new Item("100", "Air Filters", ...
Type: Posts; User: Norm
I made a slight change to the data and the order of the sorts and now none of them work.
public static void main(String [] args) {
hardware.add( new Item("100", "Air Filters", ...
Adding printlns will show you what is going on. If you have worked out the logic with paper an pencil, the print outs will show you what the code is doing so you can understand what the computer sees...
Add printlns to show what the args to compareTo() are and what it returns.
Or write some simple test code like this with several different values: System.out.println("asdd".compareTo("xxx"));
Try debugging the sort method by adding println statements to it that print out the values of the variables and shows the execution flow. The print out will show you what the computer sees and help...
It's not a bug. Its the way tab characters work. tabs are NOT a reliable way to format output unless you can set where they are defined to be. I don't know how to set tabs for the console.
If...
Post the output as text that can be copied and pasted into other posts. Can't do that with images.
Also can you add comments the parts you are talking about.
Please post the output that shows what you are talking about
On line on 79 the index you are using went past the end of the array. Check your logic to keep the index in bounds.
Remember the indexes for arrays start at 0 and go to the array length-1.
...