Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  Anargram
Language: JAVA
Code:
import java.util.Scanner;
class Anargram
{
     public static void main(String args[])
     {
          Scanner sc=new Scanner(System.in);
          System.out.println("Enter String1");
          String str1=sc.next();
          System.out.println("Enter String for Anargram checking");
          String str2=sc.next();
          char ch1[]=str1.toCharArray();
          char ch2[]=str2.toCharArray();
          int i,j,flag;
          for(i=0;i<=ch1.length-1;i++)
          {
               for(j=0;j<=ch2.length-1;j++)
               {
                    flag=0;
                    if(ch1[i]==ch2[j])
                    {
                         flag=1;
                         break;
                    }     
               }
               
          }
          if(flag==1)
               System.out.println("Anargram");
     }
}          
Comments: