In general terms, you can in fact use ==
for primitive data types in Java. The reason why it is generally not a good idea to compare floating point numbers with equality is due to floating point precision error. There are two solutions for comparison of equality of two floating point numbers (doubles), you can either use Java's BigDecimal
or have a check as to if the difference between the two numbers is less than a certain threshold (This is usually called an Epsilon value).
Using BigDecimal
BigDecimal foo = new BigDecimal(returnShortestTimeAsString() /*String Representation of your returnShortestTime() method*/);
BigDecimal bar = new BigDecimal(shortTimeAsString[1] /*String Representation of this array value*/);
if(foo.compareTo(bar) == 0 /*If they are equal*/) doStuff();
Using an Epsilon
if(Math.abs(returnShortestTime() - shortTime[1]) < Math.ulp(1.0) /*This is the Epsilon value*/) doStuff();