Java String Equal areEqual(String expected, String actual)

Here you can find the source of areEqual(String expected, String actual)

Description

are Equal

License

Open Source License

Parameter

Parameter Description
expected the expected string
actual the actual string

Return

true if the given strings are equal, false otherwise

Declaration

public static boolean areEqual(String expected, String actual) 

Method Source Code

//package com.java2s;
/*//from w  w w  . j  a  v a2 s. c  o m
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

public class Main {
    /**
     * @param expected the expected string
     * @param actual the actual string
     * @return {@code true} if the given strings are equal, {@code false} otherwise
     */
    public static boolean areEqual(String expected, String actual) {
        return expected == actual || (expected != null && expected.equals(actual));
    }
}

Related

  1. areEqual(String s1, String s2)
  2. areEqual(String s1, String s2)
  3. areEqual(String s1, String s2)
  4. areEqual(String seq1, String seq2)