Java - Write code to convert nullable Object To String

Requirements

Write code to convert nullable Object To String

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        Object d = "book2s.com";
        System.out.println(nullObjectToStringEmpty(d));
    }/*from  w  ww .  ja  v a 2 s  .c o m*/

    public static String nullObjectToStringEmpty(Object d) {
        String dual = "";
        if (d == null) {
            dual = "";
        } else
            dual = d.toString().trim();

        return dual;
    }
}

Related Exercise