Java examples for java.lang:Assert
Assert/Check whether the object is null or not.
/*/*from ww w .j ava 2s .co m*/ * oxCore is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. * * Copyright (c) 2014, Gluu */ //package com.java2s; public class Main { public static void main(String[] argv) throws Exception { Object object = "java2s.com"; String message = "java2s.com"; assertNotNull(object, message); } /** * Check whether the object is null or not. If it is, throw an exception and display the message. * * @param object the object to check. * @param message the message to display if the object is null. */ public static void assertNotNull(final Object object, final String message) { if (object == null) { throw new IllegalArgumentException(message); } } }