Sunday, January 27, 2019

package seleniumrepo;

import java.util.Arrays;
/*
 * Check whether two strings are anagram of each other
 * Ex: LISTEN <=> SILENT, TRIANGLE <=> INTEGRAL, HEART <=> EARTH
 */
public class Anagram {
public static void main(String[] args) {
String s="LISTEN";
String s1="SILENT";
char[] ch=s.toCharArray();
char[] ch1=s1.toCharArray();
Arrays.sort(ch);
Arrays.sort(ch1);
if(Arrays.equals(ch, ch1)){
                   System.out.println("True - Given number is words are anagrom of each other");
}else{
                   System.out.println("False - Given number is words are not anagrom of each other");
              }
}
}

0 comments:

Post a Comment

selenium-repo by venu

Blog helps to a student or IT employee to develop or improve skills in Software Testing.
For Online Classes Email us: gadiparthi122@mail.com

Followers

About Me

My photo
Hyderabad, Andhra Pradesh, India
I am Automation Testing Professional. I have completed my graduation in B.Tech (Computers) from JNTU Hyderabad and started my career in Software Testing accidentally since then, I passionate on learning new technologies

Contact Form

Name

Email *

Message *

Popular Posts