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));
    }/*from w  w  w  .  j  a va2 s. c  o  m*/

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

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