1, determine whether the list is empty (Map, set with the list)
if null && list.size () = =0ifnull &&! List.isEmpty ()) {}list! =null: Determine if the presence of list,null means that the list does not point to anything, and if you invoke its method at this time, a null pointer exception appears. List.isEmpty (): Determine if there are elements in the list list.size (): Judging the list has a few elements so the best way to determine if there are elements in the list is:ifnull &&! List.isEmpty ()) { //list exists and contains elements }
2. Determine if the string type data is empty
Directly with if (S.equals (")), if(!s.isempty ()),if(s.length () >0) to judge: Ignoring the case of s NULL, s pointing to an indeterminate object, Unable to invoke a method that determines the Sting object (null; (2) "". Equals (str); (3) str.length <= 0; 4) Str.isempty ();
3. Determine if the date type data is empty
// instantiation of if (date==null) {System.out.println ("date is empty");} Else {System.out.println ("date is not empty");}
Java determines whether the various types of data are empty