Java Program to Compare Two or Multiple Strings Using compareTo() Method Full Project For Beginners


Welcome folks today in this blog post we will be comparing two or multiple strings using compareTo() method in python. All the full source code of the application is shown below.




Get Started




In order to get started you need to make an file and copy paste the following code



public class CompareToExample {
   public static void main(String args[]) {
       String str1 = "String method tutorial";
       String str2 = "compareTo method example";
       String str3 = "String method tutorial";

       int var1 = str1.compareTo( str2 );
       System.out.println("str1 & str2 comparison: "+var1);

       int var2 = str1.compareTo( str3 );
       System.out.println("str1 & str3 comparison: "+var2);

       int var3 = str2.compareTo("compareTo method example");
       System.out.println("str2 & string argument comparison: "+var3);


See also  Java (Android) Send Mail with Gmail SMTP [NEW] with Gmail-Sender Library



Now if you execute the python file script by typing the below command as shown below






Leave a Reply