Java Boolean And and(boolean val1, boolean val2)

Here you can find the source of and(boolean val1, boolean val2)

Description

Returns (val1 && val2).

License

MIT License

Parameter

Parameter Description
val1 first boolean value
val2 second boolean value

Return

true if the arguments are true and false otherwise

Declaration

public static boolean and(boolean val1, boolean val2) 

Method Source Code

//package com.java2s;
/*!/*w  ww .  j  a  v  a 2 s  .  co m*/
 * mifmi-commons4j
 * https://github.com/mifmi/mifmi-commons4j
 *
 * Copyright (c) 2015 mifmi.org and other contributors
 * Released under the MIT license
 * https://opensource.org/licenses/MIT
 */

public class Main {
    /**
     * Returns (val1 && val2).
     * 
     * @param val1 first boolean value
     * @param val2 second boolean value
     * @return true if the arguments are true and false otherwise
     */
    public static boolean and(boolean val1, boolean val2) {
        return val1 && val2;
    }

    /**
     * Returns (vals[0] && vals[1] && ...).
     * 
     * @param vals boolean values
     * @return true if the arguments are true and false otherwise
     */
    public static boolean and(boolean... vals) {
        if (vals == null || vals.length == 0) {
            return false;
        }

        for (boolean val : vals) {
            if (!val) {
                return false;
            }
        }

        return true;
    }
}

Related

  1. and(boolean a, boolean b)
  2. and(boolean b1, boolean b2)
  3. and(boolean... bools)
  4. and(boolean... bs)
  5. and(Boolean... operands)
  6. andBoolOperand(Boolean o, Boolean a)