Check if current element is smaller than secondSmallest simply update the latter
else if ( arr [ i ] < secondSmallest ) { secondSmallest = arr [ i ] ; } } if ( 2 * smallest <= secondSmallest ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; }