Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args){
- String text = "Madam, I'm Adam!";
- //String text = "Hello, World!";
- if (text==null){
- System.out.println("empty");
- return;
- }
- else {
- StringBuilder s = new StringBuilder((text.toLowerCase()).replaceAll("[^A-Za-z1-9]+", ""));
- String s1 = s.toString();
- StringBuilder sr = s.reverse();
- String s2 = sr.toString();
- System.out.println(s1);
- System.out.println(s2);
- System.out.println(s1.equals(s2));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement