Add HW01 exercises

This commit is contained in:
2026-04-15 17:37:31 +00:00
commit 24ea3fcd29
5 changed files with 103 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import java.util.Scanner;
public class Palindrome {
static boolean isPalin(String s){
int i = 0;
int j = s.length()-1;
while (i < j) {
if (s.charAt(i) != s.charAt(j)){
return false;
}
i++;
j--;
}
return true;
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
boolean isPal = isPalin(str);
System.out.println("is "+ str+ " palindrome? "+ isPal);
}
}