Convert value to String with Objects.toString - Java Object Oriented Design

Java examples for Object Oriented Design:Objects Utility

Description

Convert value to String with Objects.toString

Demo Code

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

}

Result


Related Tutorials