Guest User

Untitled

a guest
Nov 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public class Test {
  2.  
  3. public List<String> getListWithNull() {
  4.  
  5. return null;
  6. }
  7.  
  8. public List<String> getList() {
  9.  
  10. return Collections.emptyList();
  11. }
  12.  
  13. public Map<String, String> getMap() {
  14.  
  15. return Collections.EMPTY_MAP;
  16. }
  17.  
  18. public static void main(String[] args) {
  19. Test test = new Test();
  20.  
  21. List<String> strings = test.getList();
  22.  
  23. for (String i:strings)
  24. System.out.println(i);
  25.  
  26. if(!strings.isEmpty())
  27. // do
  28.  
  29. List<String> stringnull=test.getListWithNull();
  30.  
  31. if(stringnull!=null)
  32. // do
  33. }}
Add Comment
Please, Sign In to add comment