java - Can new Double(String) ever return a null? -
this question has answer here:
- can constructor return null object? 11 answers
given code
final double price = new double(somestring); if(price != null <...>) {
am correct in assuming price can never null here?
read specifications: section 15.9.4 of jls:
the value of class instance creation expression reference newly created object of specified class. every time expression evaluated, fresh object created.
a constructor therefore can never return null. however, java.lang.outofmemoryerror
may occur.
Comments
Post a Comment