EssayNICE | 24/7 Homework Help

Essaynice Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

I have a TreeMap. I conduct orders by price using a comparator. shop.addProduct(new Phone(“Samsung”,799),shop.countProduct); shop.addProduct(new Food(“Milk”,4),s

by | Sep 9, 2023 | computerscience

I have a TreeMap<Product, Integer>.I conduct orders by price using a comparator.

        shop.addProduct(new Phone(“Samsung”,799),shop.countProduct);        shop.addProduct(new Food(“Milk”,4),shop.countProduct);        shop.addProduct(new Food(“Bread”,2),shop.countProduct);        shop.addProduct(new Toy(“Lego”,130),shop.countProduct);

this will be the result

{Bread_2_=2, Milk_4_=1, Lego_130_=3, Samsung_799_=0}

Question: I can’t figure out how to make countProduct count in ascending order

Expected Result{Bread_2_=0, Milk_4_=1, Lego_130_=2, Samsung_799_=3}

Tried to create a comparator by quantity

  

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

Open chat
1
Powered by essaynice
Hello! Welcome to to our whatapp support.
We offer READY solutions, HIGH QUALITY PLAGIARISM FREE essays and term-papers.

We are online and ready to help