Here you can find the source of null2String(Object obj)
null
to empty string, otherwise returns it directly.
Parameter | Description |
---|---|
string | The nullable string |
public static String null2String(Object obj)
//package com.java2s; public class Main { /**//from w w w .j av a 2 s. c o m * Converts <code>null</code> to empty string, otherwise returns it * directly. * * @param string * The nullable string * @return empty string if passed in string is null, or original string * without any change */ public static String null2String(Object obj) { return obj == null ? "" : obj.toString(); } public static String null2String(String str) { return str == null ? "" : str; } }