Write code to get Null If empty String using tenary operator
//package com.book2s; public class Main { public static void main(String[] argv) { String str = "book2s.com"; System.out.println(getNullIfemptyString(str)); }/*from w w w . jav a 2 s . c om*/ public static String getNullIfemptyString(String str) { return (str == null) || (str.trim().length() == 0) ? null : str; } }