Java examples for Object Oriented Design:Objects Utility
Convert value to String with Objects.toString
import java.util.Objects; public class Main { public static void main(String[] args) { // toString() method test System.out.println("toString(null) is " + Objects.toString(null)); System.out.println("toString(null, \"XXX\") is " + Objects.toString(null, "XXX")); }//from w w w . j a va 2s . co m }