[JAVA] Difference between element 0, null and empty string (check in list)

[] 0 Element 0


List<String> sampleList1 = new ArrayList<String>();
System.out.println(sampleList1);
System.out.println(sampleList1.size());

The contents are null


List<String> sampleList2;
//System.out.println(sampleList2);← Compile error that the local variable sampleList2 may not have been initialized.

[] 1 The content has only one empty string element

List<String> sampleList3 = new ArrayList<String>();
sampleList3.add("");
System.out.println(sampleList3);
System.out.println(sampleList3.size());

Recommended Posts

Difference between element 0, null and empty string (check in list)
Difference between List and ArrayList
Difference between final and Immutable in Java
Difference between pop () and peek () in stack
Difference between getText () and getAttribute () in Selenium
Difference between "|| =" and "instance_variable_defined?" In Ruby memoization
Arrylist and linked list difference in java
Difference between EMPTY_ELEMENTDATA and DEFAULTCAPACITY_EMPTY_ELEMENTDATA in ArrayList
Difference between int and Integer in Java
[Java] Understand the difference between List and Set
[Java] Difference between equals and == in a character string that is a reference type
Difference between vh and%
Difference between i ++ and ++ i
Null, empty string, blank
About the difference between classes and instances in Ruby
Difference between new and create in Rais action controller
[Java] Difference between static final and final in member variables
[Java] Difference between == and equals
Rails: Difference between resources and resources
Difference between puts and print
Difference between CUI and GUI
About the difference between "(double quotation)" and "single quotation" in Ruby
Difference between variables and instance variables
Jersey --What is Difference Between bind and bindAsContract in HK2?
Difference between mockito-core and mockito-all
Difference between class and instance
Difference between bundle and bundle install
[Java] Check the difference between orElse and orElseGet with IntStream
Difference between ArrayList and LinkedList
Difference between render and redirect_to
StringUtils.isNotBlank is convenient for empty judgment and null judgment in java
Difference between .bashrc and .bash_profile
Difference between StringBuilder and StringBuffer
Difference between render and redirect_to
Difference between render and redirect_to
Difference between Not Null constraint and model validation (presence: true)
Is short-circuit evaluation really fast? Difference between && and & in Java
[Java] I want to check that the elements in the list are null or empty [Collection Utils]
[Ruby] Difference between symbol variables and character string variables. About the difference between [: a] and ['a'].
Difference between byCharWrapping and byWordWrapping of UI Label in Japanese display
[Ruby] Difference between get and post
Difference between instance method and class method
Difference between render method and redirect_to
Find the difference between List types
Difference between == operator and equals method
[Java] Difference between Hashmap and HashTable
[Terminal] Difference between irb and pry
JavaServlet: Difference between executeQuery and executeUpdate
[Ruby] Difference between is_a? And instance_of?
Difference between == operator and eqals method
Rough difference between RSpec and minitest
[Rails] Difference between find and find_by
Understand the difference between each_with_index and each.with_index
Difference between instance variable and class variable
Null / empty string judgment 2.0 using Optional
[JAVA] Difference between abstract and interface
Difference between Thymeleaf @RestController and @Controller
Difference between Stream map and flatMap
[Java] Difference between array and ArrayList
Difference between primitive type and reference type
Difference between string.getByte () and Hex.decodeHex (string.toCharaArray ())