Java - Write code to Check if a string is correctly set.

Requirements

Write code to Check if a string is correctly set.

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String toCheck = "book2s.com";
        System.out.println(isStringSet(toCheck));
    }//from   w ww  .  j  a va 2s  . co m

    /**
     * Checks if a string is correctly set. In particular this methods return
     * true iff toCheck is not null and the content is not equal to the string
     * NULL
     * 
     * @param toCheck
     * @return true iff the given string is not null and the content is not equal to NULL
     */
    public static boolean isStringSet(String toCheck) {
        return toCheck != null && !toCheck.trim().equalsIgnoreCase("NULL");
    }
}