Java - Write code to convert a string to To Not Null value, using conditional operator

Requirements

Write code to convert a string to To Not Null value

A not null value of a string is ""

Hint

You can use the conditional operator.

Demo

//package com.book2s;

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

    public static String ToNotNull(String s) {
        return s == null ? "" : s;
    }
}

Related Exercise