Wednesday 25 April 2018

Handling NULL POINTER EXCEPTION

1ST WAY  USAGE:
if( (Relational.ISNULL(test_string)) || ("null".equals(test_string)) || ("".equals(test_string))   )
System.out.println("HAS GOT A NULL VALUE ");
    else
     
        System.out.println("HAS GOT A VALID VALUE ");


2ND WAY USAGE:

( (Relational.ISNULL(test_string)) || ("null".equals(test_string)) || ("".equals(test_string))   )
? "HAVING NULL" :  "HAVING DATA"


=======================================================
Below is the Tested Talend code in DETAIL with various ways of NULL data:
=======================================================

String test_string="TALEND";

System.out.println("\ntest_string=\"TALEND\";");
if( (Relational.ISNULL(test_string)) || ("null".equals(test_string)) || ("".equals(test_string))   )
System.out.println("HAS GOT A NULL VALUE ");
    else
     
        System.out.println("HAS GOT A VALID VALUE ");

test_string="null";

System.out.println("\ntest_string=\"null\";");
if( (Relational.ISNULL(test_string)) || ("null".equals(test_string)) || ("".equals(test_string))   )
System.out.println("HAS GOT A NULL VALUE ");
    else
     
        System.out.println("HAS GOT A VALID VALUE ");

test_string="";
System.out.println("\ntest_string=\"\";");

if( (Relational.ISNULL(test_string)) || ("null".equals(test_string)) || ("".equals(test_string))   )
System.out.println("HAS GOT A NULL VALUE ");
    else
     
        System.out.println("HAS GOT A VALID VALUE ");


test_string=null;

System.out.println("\ntest_string=null;");

if( (Relational.ISNULL(test_string)) || ("null".equals(test_string)) || ("".equals(test_string))   )
System.out.println("HAS GOT A NULL VALUE ");
    else
     
        System.out.println("HAS GOT A VALID VALUE ");
     

COURTS : CASES : LAWYERS : JUDGES : ::::::::: VICTIMS : ACCUSED

  *We have got so many SMART people in our COUNTRY. *we have got so many IIT completed SMART students in our COUNTRY. * we have got so many ...