Java - Write code to create a function to convert object to String and handle null value

Requirements

Write code to create a function to convert object to String and handle null value

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        Object object = "book2s.com";
        System.out.println(toString(object));
    }//from   w  w  w  . java2  s .  c om

    public static String toString(Object object) {
        return object == null ? "(null)" : object.toString();
    }
}