Skip to main content

Posts

Showing posts from January, 2017

Anagram Strings

PROGRAM: ANAGRAM STRINGS Two strings are anagram if they are written using same exact letters,ignoring space, punctuation and capitalization. Each letter should have the same count in both strings. For Example: Mary and Army are anagram of each other. SYNTAX: import java.io.*; class anagram {     public static void main(String args[])throws IOException     {         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));         System.out.println("Enter Two Strings to check whether they are anagram or not");         String s1=br.readLine();         String s2=br.readLine();         String nstr="",ntr="";int count=0;         for(int i=0;i less than s1 length;i++)         {             if(Character.isLetter(s1.charAt(i)))             {                 nstr+=s1.charAt(i);             }         }         for(int i=0;i  less than s2 length;i++)         {             if(Character.isLetter(s2.charAt(i)))