Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual J#
Visual J# Reference
java.lang.String
 java.lang.String.equals(Object obj)

  Switch on low bandwidth view
Visual J# Reference
java.lang.String.equals(Object obj)

Determines whether two String objects contain the same data.

J#
public boolean equals(Object obj)

Parameters

Parameter Description

obj

A java.lang.String object to compare against the current String for equality.

true if the two String objects contain the same data; false otherwise.

// string_equals.jsl

public class Program
{
    public static void main(String[] args)
    {
        String physicist1 = "Albert Einstein";
        String physicist2 = "Max Planck";
        String physicist3 = "Albert Einstein";

        // Are any of the above Strings equal to one another?
        boolean equals1 = physicist1.equals(physicist2);
        boolean equals2 = physicist1.equals(physicist3);

        // Display the results of the equality checks.
        System.out.println("\"" + physicist1 + "\" equals \"" +
            physicist2 + "\"? " + equals1);
        System.out.println("\"" + physicist1 + "\" equals \"" +
            physicist3 + "\"? " + equals2);
    }
}

/*
Output:
"Albert Einstein" equals "Max Planck"? false
"Albert Einstein" equals "Albert Einstein"? true
*/

Reference

java.lang.String

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker