Friday, April 5, 2019

compareTo()

compareTo()                                                         edited by diya


import java.util.Scanner;
class p19
{
public static void main(String args[])
{
Scanner n=new Scanner(System.in);

System.out.println("Enter a string");
String s1=n.nextLine();
System.out.println("Enter a string");
String s2=n.nextLine();
int a=s1.compareTo(s2);
System.out.println("after comparesion");
System.out.println(a);

}

}



D:\>javac p19.java

D:\>java p19
Enter a string
diya
Enter a string
sayan
after comparesion
-15

D:\>

No comments:

Post a Comment