How To Check If An Object Reference Is Null Or Not? | Java Tips And Tricks

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ย. 2024
  • Usually we use if statement combined with == or != operators to check if an object reference is null or not. We do this to validate arguments passed to constructors or methods doesn’t contain a null value.
    The solution is to use the java.util.Objects class. This static utility class provides methods like requireNonNull() to check if the specified object reference is not null. If null it will throw a NullPointerException.
    #javaprogramming #javatutorial #javatutorialforbeginners
    ______________________________
    About AsappJobs:
    AsappJobs is building an education content marketplace platform called letsgrow.tech. Monetise your knowledge & doubts!
    For more details please visit:
    website: letsgrow.tech
    linkedIn page : / asappjobs
    facebook page : / asappjobs
    twitter page : / asappjobs
    ___________________
    Visit to our playlist for more interesting videos:
    Data Structures & Algorithms Complete Course 2020 🔥 (Designed To Crack Interviews):
    • Data Structures & Algo...
    System Design By Industry Experts:
    • System Design By Indus...
    System Design Mini Series By Experts:
    • System Design Mini Ser...
    How To Crack Graph Interview:
    • How To Crack Graph Int...
    System Design Interview Preparation:
    • System Design Intervie...
    Hands On With Microsoft Azure:
    • Hands On With Microsof...
    Cloud Computing:
    • Cloud Computing
    Interview With Selected Candidate:
    • Interview With Selecte...
    Interview Tips And Questions By Selected Candidate:
    • Interview Tips And Que...
    Java Interview Questions & Answers:
    • Java Interview Questio...
    Java Fundamentals And Internal Mechanism:
    • Java Fundamentals And ...
    Data Structure And Algorithms Interview Questions And Answers:
    • Data Structure And Alg...
    Data Structure And Algorithms Interview Q&A (Quick Prep):
    • Data Structure And Alg...
    Interview Puzzles:
    • Interview Puzzles
    Interview Preparation Complete Guidelines:
    • Interview Preparation ...
    Data Structure and Algorithms Full Course:
    • Data Structure and Alg...
    ----------------------------
    contact details:
    Email ID: rajeev@asappjobs.com
    -----------------------------
    Please like, comment and share this video to your network
    and don't forgot to subscribe and hit the bell icon ;)
    Thanks,
    AsappJobs Team

ความคิดเห็น • 9

  • @PrabhatKumarJ
    @PrabhatKumarJ 5 ปีที่แล้ว +1

    I was expecting something interesting from the title of the video. But the topic tells about how to validate method parameter with help of Java util. java.util.Objects#requireNonNull(T) is just a utility method introduced in Java 7 which replaces boilerplate code nothing new. Looking forward for something interesting topics...

    • @AsappJobs
      @AsappJobs  5 ปีที่แล้ว

      sure prabhat .... will keep that in mind for further videos

  • @arnavshukla7268
    @arnavshukla7268 3 ปีที่แล้ว +1

    I am getting null object reference error how to fix

    • @AsappJobs
      @AsappJobs  3 ปีที่แล้ว

      put a null condition before using that object

    • @arnavshukla7268
      @arnavshukla7268 3 ปีที่แล้ว

      I have linked the button with my layout initialized it with null it is not in any other layout still getting error

  • @sachidanandapallai6016
    @sachidanandapallai6016 3 ปีที่แล้ว +1

    indi mein bol deta

    • @AsappJobs
      @AsappJobs  3 ปีที่แล้ว

      Unfortunately we can't, because this channel is for english audience. But may be soon we start hindi channel as well. will let you know then!