package stringcompare;
public class StringCompare {
public static void main(String[] args) {
String myName="Bangladesh";
String YourName="Africa";
char c='k';
System.out.println("Index of k from myName:"+myName.indexOf(c));
System.out.println("Index of k from yourName:"+YourName.indexOf(c));
int result=myName.compareTo(YourName);
if(result>0){
System.out.println("greater:"+result);
}
else if(result<0){
System.out.println("less:"+result);
}
else if(result==0){
System.out.println("Equal:"+result);
}
}
}
No comments:
Post a Comment