Java8 | 42 | Integer Overflow/underflow Issue while using Comparator

Поділитися
Вставка
  • Опубліковано 23 жов 2024
  • In the previous video, we learned how to sort with the help of a comparator interface. When using a comparator interface we will usually use the arithmetic operator for its implementation. This is fine for most of the cases, however, in some edge cases, it's not recommended, especially when we are dealing with Integer's max or min value. In these scenarios, we will encounter an integer overflow issue and we will not get the desired output.
    *️⃣What is an example of integer overflow/underflow?
    When you go above the maximum value of the signed integer, the result usually becomes a negative number. For example, 2,147,483,647 +1 is usually −2,147,483,648. When you go below the minimum value (underflow), the result usually becomes a positive number. For example, −2,147,483,648 − 1 is usually 2,147,483,647.
    *️⃣How can we avoid this integer overflow/underflow while using a comparator?
    by using the Integer.compare(obj1, obj2) function, we can avoid this problem.
    Support by donating:
    ---------------------------------
    Google Pay UPI Id: arulprasath36@okicici
    Name: Arulprasath
    Email: arulprasath36@gmail.com
    Follow me on Linked In: / arulprasath-ranganatha...
    Instagram: im_arulprasath
    website: www.arulprasathranganathan.com
    You can watch my other tutorials
    ------------------------------------------------------
    Selenium basics: bit.ly/2XtOt1F
    Selenium Advanced: bit.ly/2WYieZe
    TestNG Absolute Beginner Guide: bit.ly/2N6xgaM
    Data-driven framework: bit.ly/2WVjSFT
    Page Object Model: bit.ly/2IAXJZR
    Framework development using POM and Cucumber: rb.gy/fer4sw
    Keyword driven framework development: rb.gy/gosduk
    How to write XPath on our own: bit.ly/2KwMLql
    Must know Java concepts for Selenium: bit.ly/31Ro7G8
    Selenium Interview Questions: bit.ly/2N6xu1F
    Java for Selenium Automation: bit.ly/2IylOAh
    Maven beginner guide: bit.ly/2Rsigm0
    GitHub Absolute beginner Guide: bit.ly/2Kxdzqj
    REST Web services beginner guide: bit.ly/2N69rQq
    Cucumber absolute beginner guide: bit.ly/2X0lSBB
    Acceptance Testing (Fitnesse) beginner guide: bit.ly/2Y6oE55
    Jenkins beginner guide: bit.ly/2X39fGb
    Jmeter beginner tutorials: bit.ly/32achqW
    Java programs for Interview: bit.ly/3AZ5u4M
    Frequently Asked Interview questions for testers: bit.ly/3xFfyhm
    Agile beginner tutorials: bit.ly/3khmT2z
    Jira beginner tutorials : bit.ly/2TZLE97
    Rest Assured beginner tutorials: bit.ly/3i4lpGw
    Selenium Exceptions: bit.ly/36BpYCS
    Manual testing tutorials: rb.gy/htjdm4
    Freshers Tips and Guidance: rb.gy/m97ze8
    ISTQB Foundation level Videos: rb.gy/erkss9
    Postman Absolute beginner Tutorials: rb.gy/u5hds6
    Roadmap for Freshers and Professionals: rb.gy/vuhvap
    Complete Rest Assured Tutorials: rb.gy/3wgta9

КОМЕНТАРІ •