import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static boolean stringCompare(String str1, String str2) {
int l1 = str1.length();
int l2 = str2.length();
int lmin = Math.min(l1, l2);
for (int i = 0; i < lmin; i++) {
int str1_ch = (int)str1.charAt(i);
int str2_ch = (int)str2.charAt(i);
if (str1_ch != str2_ch) {
return false;
}
}
// الحافة لسلاسل مثل
if (l1 != l2) {
return false;
}
// إذا لم يكن أي من الشروط المذكورة أعلاه صحيحًا ،
// يعني أن كلا السلاسل متساوية
else {
return true;
}
}
public static void main(String[] args) {
Scanner sca = new Scanner(System.in);
ArrayList<String> words = new ArrayList<String>();
words.add("Hello");
System.out.println("What is your name? ");
String name = sca.next();
System.out.print("Message: ");
String message = sca.next();
String reply = "Reply: ";
if(stringCompare(message, words.get(0))){
System.out.println(reply+"Hi!, how are you "+name);
message = sca.next();
}
else{
System.out.println("not understand");
}
}
}