Code:
import java.util.Scanner;
public class Str_Compare
{
public static void main(String args[])
{
String s1;
String s2;
String a;
Scanner s=new Scanner(System.in);
System.out.print("Please enter first string : ");
s1=s.next();
System.out.print("Please enter second string : ");
s2=s.next();
a=stringcompare(s1,s2);
System.out.print("Larger string is "+a);
}
static String stringcompare(String s3, String s4)
{
int n=0;
if(n>(s3).compareTo(s4))
return(s3);
else if(n<(s3).compareTo(s4))
return(s4);
else
return("both strings are equal");
}
}
No comments:
Post a Comment