Java - Write code to Returns an empty String if string is null.

Requirements

Write code to Returns an empty String if string is null.

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String string = "book2s.com";
        System.out.println(scrubNull(string));
    }/*ww  w .  j  a  v a  2 s.c  om*/

    public static String scrubNull(String string) {
        return (string == null) ? "" : string;
    }

    public static String scrubNull(String string, String aDefault) {
        return (string == null) ? aDefault : string;
    }
}