SHARE
TWEET

OptionalInt vs ?:

DulcetAirman Aug 28th, 2018 (edited) 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   public static void main(String[] args) {
  2.     Integer stockPrice = getStockPrice();
  3.     int i = OptionalInt.ofNullable(stockPrice).orElse(0);
  4.     int j = stockPrice == null ? 0 : stockPrice;
  5.   }
  6.  
  7.   static Integer getStockPrice() {
  8.     return null;
  9.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top