We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Java
- Strings
- Java String Reverse
- Discussions
Java String Reverse
Java String Reverse
Sort by
recency
|
1816 Discussions
|
Please Login in order to post a comment
This is a simple code with Java 15 :
public static void main(String[] args) {
import java.io.; import java.util.;
public class Solution {
}
// Java program to check if a given string is a palindrome import java.io.; import java.util.;
public class Solution {
}
This Java program checks whether a given string A is a palindrome efficiently using character comparisons. It iterates through the first half of the string and checks if each character from the start matches its corresponding character from the end. If any characters do not match, it concludes that the string is not a palindrome. The program prints "Yes" if the string is a palindrome and "No" otherwise.
Time complexity : O(n/2). Hope this helps clarify the problem.
Two different ways to solve this problem. Hope you will find this helpful.
import java.util.Scanner;
public class Main{ public static void main(String[] args) { Scanner scan = new Scanner(System.in);
}