import java.io.*;
public class compare
{
public static void main(String []args)
{
String str,str1;
try
{
DataInputStream cin=new DataInputStream(System.in);
System.out.println("Enter first String ");
str=cin.readLine();
System.out.println("Enter another String ");
str1=cin.readLine();
int i=str.compareTo(str1);
if(i<0)
{
System.out.println(str+" is large than "+str1);
}
else if(i>0)
{
System.out.println(str1+" is large than "+str);
}
else if(i==0)
{
System.out.println(str1+" &"+str+" both string are equal");
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
public class compare
{
public static void main(String []args)
{
String str,str1;
try
{
DataInputStream cin=new DataInputStream(System.in);
System.out.println("Enter first String ");
str=cin.readLine();
System.out.println("Enter another String ");
str1=cin.readLine();
int i=str.compareTo(str1);
if(i<0)
{
System.out.println(str+" is large than "+str1);
}
else if(i>0)
{
System.out.println(str1+" is large than "+str);
}
else if(i==0)
{
System.out.println(str1+" &"+str+" both string are equal");
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
No comments:
Post a Comment