Java - Write code to return default value for Null Or Blank string using if statement

Requirements

Write code to filter Null Or Blank

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String input = "book2s.com";
        String nullOrBlankDefault = "book2s.com";
        System.out.println(filterNullOrBlank(input, nullOrBlankDefault));
    }//  w w  w.j  av a 2s  .  co m

    public static String filterNullOrBlank(String input,
            String nullOrBlankDefault) {
        if (input == null || input.equals("") || input.trim().equals("")) {
            return nullOrBlankDefault;
        } else {
            return input;//input.trim();
        }
    }
}

Related Exercise