-1

I have following code:

String tmpTotalCost = "";    
tmpTotalCost = request.getParameter("TotalCost");

if(tmpTotalCost == null) 
    tmpTotalCost = "";
if(tmpTotalCost == "") 
    tmpTotalCost = "0.00";

What would be the best way to check if tmpTotalCost is null or empty? I would always write a code that would finish the job, but I never thought about performance.

Angelina
  • 2,175
  • 10
  • 42
  • 82

1 Answers1

1

I would recommend you to use StringUtils from Apache Commons Lang library. https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/StringUtils.html

yogidilip
  • 790
  • 6
  • 21