Compare Two Strings In Java Using Inbuilt Fun Code Example

Snippet 1

  int str1.compareTo(String str2) 

Snippet 2

  if (aName.equals(anotherName))
        { 
            System.out.println(aName + " equals " + anotherName);
        }
        else 
            { 
                System.out.println(aName + " does not equal " +anotherName );
                           
            } 

Copyright © Code Fetcher 2020

 

 

Published

Leave a comment

Your email address will not be published. Required fields are marked *