Here you can find the source of toInt(Integer n)
Parameter | Description |
---|---|
n | a parameter |
defaultValue | a parameter |
public static int toInt(Integer n)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w . j a v a 2s. c om*/ * Returns either an n converted to int, or 0 if n equals {@code null} * @param n * @param defaultValue * @return */ public static int toInt(Integer n) { return n != null ? n : 0; } /** * Returns either an n converted to int, or default value if n equals {@code null} * @param n * @param defaultValue * @return */ public static int toInt(Integer n, int defaultValue) { return n != null ? n : defaultValue; } }