Sunday, 7 June 2015

Program to check whether two strings are anagrams of each other

import java.io.*;
public class Anagrams
{
  public static void main(String args[]) throws Exception
  {
    Anagrams a = new Anagrams();
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    System.out.print("Enter first string: ");
    String str1 = br.readLine();
     
    System.out.print("Enter second string: ");
    String str2 = br.readLine();
    
    int flag = a.Anagram(str1, str2);

    if (flag==0)
    {
      System.out.print("\nResult: "+str1+" and "+str2+" are anagrams.");
    }
    else
    {
      System.out.print("\nResult: "+str1+" and "+str2+" are not anagrams.");
    }
    
    System.out.println();
  }


  public int Anagram(String str1,String str2)
  {
    if (str1.equals(str2))
    {
      return 0;
    }

    return 1;
  }
}
Output:
Enter first string: ana
Enter second string: ana

Result: ana and ana are anagrams.

Output2:
Enter first string: aana
Enter second string: ana

Result: aana and ana are not anagrams.

83 comments:

  1. Learning new technolgoy would help oneself at hard part of their career. And staying updated is the only way to survive in current position. Your content tells the same. Thanks for sharing this information in here. Keep blogging like this.

    JAVA J2EE Training in Chennai | JAVA Training in Chennai | Hadoop training in chennai

    ReplyDelete
    Replies
    1. I have read your blog its very attractive and impressive. I like it your blog.

      Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

      Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 8 online training JavaEE Training in Chennai Java EE Training in Chennai

      Delete
  2. Thanks Mathew Stephen...n u said absolutely right that if we want to be in current position then we need to be updated...

    ReplyDelete
  3. Really cool post, highly informative and professionally written and I am glad to be a visitor of this perfect blog, thank you for this rare info! , Regards, servicenow training in hyderabad

    ReplyDelete
  4. Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
    Web Designing Course in Chennai | web designing training in chennai

    ReplyDelete
  5. Thanks for sharing this unique and informative content which provided me the required information.
    Java Training in Chennai | JAVA Course in Chennai

    ReplyDelete
  6. Thanks for sharing the information about the java and keep updating us.
    JAVA Training in Chennai

    Best JAVA Training in Chennai

    ReplyDelete
  7. I agree with your thoughts!!! As the demand of java programming application keeps on increasing, there is massive demand for java professionals in software development industries. Thus, taking training will assist students to be skilled java developers in leading MNCs.Best Java Training in Chennai | Java Courses in Chennai|J2EE Training in Chennai

    ReplyDelete
  8. Thanks for sharing this useful and valuable information, keep updating your post.
    IT Job Training in Chennai

    ReplyDelete
  9. The expansion of internet and intelligence in business process lead the way to huge volume of data. It is important to maintain and process these data to be efficient in data handling. Hadoop Training in Chennai | Big Data Training in Chennai

    ReplyDelete
  10. I have read your blog its very Interesting. Thanks for sharing. Call for low cost ERP software. ERP in Chennai | ERP Software in Chennai

    ReplyDelete
  11. Thank you for this valuable information. I have got some important suggestions from it. I'm working in Brave Technologies Private Limited. We provides lowest price of ERP Software for our clients. Contact us on info@bravetechnologies.in. ERP Providers in Chennai

    ReplyDelete
  12. Nice post. Very interesting to read. Thank you for Sharing.
    erp software in chennai

    ReplyDelete
  13. Hi, like you post its more informative and thanks for sharing with us.
    Web D School

    ReplyDelete
  14. SV Soft Solutions is offering best Java online training with 100% job assistance and high quality training facilities and well expert faculty .
    to Register you free demo please visit Java Online Training Institute with Job Support

    ReplyDelete
  15. I am so happy to read your blog. Thank you for updating such a wonderful post..Selenium Training Institute in Chennai | Selenium Training Institute in Velachery

    ReplyDelete
  16. Good one, very informative.. thanks for sharing your views and ideas.. it is very useful to me.. thanks once again..
    Best Linux Training Institute in Chennai | No.1 Linux Training Center in Chennai | Red Hat Linux Training Center in Chennai

    ReplyDelete
  17. Thanks for the useful post. Keep posting more like this.
    Webdesign Lüdenscheid

    ReplyDelete
  18. Java is programming language which is used in almost all the applications and games which are on the web. Java is being used extensively and it will be used extensively in near future. So getting trained in Java will surely be helpful.
    Thanks,
    sap training institute

    ReplyDelete
  19. Thank you for this valuable information. I have got some important suggestions from it. Get your business to the next level in simple steps.
    Sap BW Training

    ReplyDelete
  20. Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
    Android Training in Chennai
    Ios Training in Chennai

    ReplyDelete
  21. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

    Java Training in Chennai

    Java Training in BangaloreNeeded to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

    Java Training in Chennai

    ReplyDelete
  22. Your website content nice nice and interesting to observe.
    ssd festplatte samsung

    ReplyDelete

  23. Thanks For Your valuable posting, it was very informative
    Internet Marketing Dienstleistungen

    ReplyDelete
  24. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.

    java training in bangalore

    ReplyDelete
  25. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.

    java Training in Chennai

    Java Training in Bangalore

    ReplyDelete
  26. I gathered useful information on this point . Thank you posting relative information and its now becoming easier to complete this assignment.
    ME/M.Tech Project Center in Chennai | ME/M.Tech Project Center in Velachery

    ReplyDelete
  27. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...Python Training Institute in Chennai | Python Training in Velachery | Python Training Center in Chennai

    ReplyDelete
  28. There are lots of information about latest technology and how to get trained in them but this is a unique one according to me. The strategy you have updated here will make me to get trained in future technologies. By the way you are running a great blog. Thanks for sharing this.
    B.Com Project Center in Chennai | B.Com Project Center in Velachery

    ReplyDelete
  29. I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. 

    Java Training Center in Chennai | Best J2EE Training Center in Chennai | No.1 Java Training Institution in Velachery | Core Java Training in Chennai

    ReplyDelete
  30. Very good informative article..Thanks for sharing such nice articleDotNet Project Center in Chennai | DotNet Project Center in Velachery

    ReplyDelete
  31. The website is looking bit flashy and it catches the visitors eyes. A design is pretty simple .
    regionale stellenbörse

    ReplyDelete
  32. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    aws training in Chennai

    ReplyDelete
  33. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    aws training in Chennai

    ReplyDelete
  34. hese thoughts just blew my mind..I am glad you have posted this.Summer Courses in Chrompet | Summer Courses in Chennai

    ReplyDelete
  35. Those guidelines additionally worked to become a good way to
    recognize that other people online have the identical fervor like mine
    to grasp great deal more around this condition.

    white label website builder

    ReplyDelete
  36. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.

    digital marketing training in chennai

    ReplyDelete
  37. I found a lot of interesting information here. Really good post
    How was the universe created

    ReplyDelete
  38. Those guidelines additionally worked to become a good way to
    recognize that other people online have the identical fervor like mine
    to grasp great deal more around this condition.

    digital marketing training in chennai

    ReplyDelete
  39. Great one,You have done a great job by sharing this content,Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.

    Python Training in Chennai
    Python Training

    ReplyDelete
  40. All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.
    Selenium Training in Chennai

    AWS Training in Chennai

    Python Training in Chennai

    ReplyDelete
  41. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
    digital marketing training in marathahalli

    digital marketing training in rajajinagar

    Digital Marketing online training

    full stack developer training in pune

    ReplyDelete
  42. Outstanding blog post, I have marked your site so ideally I’ll see much more on this subject in the foreseeable future.
    Click here:
    angularjs training in sholinganallur
    Click here:
    angularjs training in btm

    ReplyDelete
  43. I love the blog. Great post. It is very true, people must learn how to learn before they can learn. lol i know it sounds funny but its very true. . .
    Click here:
    Microsoft azure training in chennai
    Click here:
    Microsoft azure training in annanagar

    ReplyDelete
  44. The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea. here by i also want to share this.

    angularjs Training in chennai
    angularjs Training in chennai

    angularjs-Training in tambaram

    angularjs-Training in sholinganallur

    angularjs-Training in velachery

    ReplyDelete
  45. Good Post, I am a big believer in posting comments on sites to let the blog writers know that they ve added something advantageous to the world wide web.
    python training in tambaram | python training in annanagar | python training in jayanagar

    ReplyDelete
  46. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    Online DevOps Certification Course - Gangboard
    Best Devops Training institute in Chennai

    ReplyDelete
  47. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

    rpa training in velachery| rpa training in tambaram |rpa training in sholinganallur | rpa training in annanagar| rpa training in kalyannagar

    ReplyDelete
  48. Thank you for sharing such great information with us. I really appreciate everything that you’ve done here and am glad to know that you really care about the world that we live in.
    Android Training in Chennai
    Android Course in Chennai
    Android Development Course in Chennai
    Android app Development Course in Chennai
    Android Training Chennai

    ReplyDelete
  49. Really you have done great job,There are may person searching about that now they will find enough resources by your post
    Java training in Chennai | Java training in Bangalore

    Java interview questions and answers | Core Java interview questions and answers

    ReplyDelete
  50. All the points you described so beautiful. Every time i read your blog content and i so surprised that how you can write so well.
    Android Training in Chennai | Android Training in Kanchipuram

    ReplyDelete
  51. Amazon has a simple web services interface that you can use to store and retrieve any amount of data, at any time, from anywhere on the web. Amazon Web Services (AWS) is a secure cloud services platform, offering compute power, database storage, content delivery and other functionality to help businesses scale and grow.For more information visit.
    aws online training
    aws training in hyderabad
    aws online training in hyderabad

    ReplyDelete
  52. It's very great post... Really you are... done a wonderful job Keep up the good work and continue sharing like this.
    Robotic Process Automation Training in Chennai | Robotic Process Automation Training in Taramani

    ReplyDelete
  53. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
    Microsoft Advanced Excel and VBA Macros Training in Chennai | Microsoft Advanced Excel and VBA Macros Training in Kanchipuram

    ReplyDelete
  54. It's very great post... Really you are... done a wonderful job Keep up the good work and continue sharing like this.
    iOS Training in Chennai | iOS Training in Tambaram

    ReplyDelete
  55. Very informative blog. Thanks for sharing such good information and keep on updating.
    Dot net Training in Chennai | Dot net Training in Perungudi

    ReplyDelete
  56. The provided information’s are very useful to me.Thanks for sharing.Keep updating your blog...
    Python Training in Chennai | Python Training in Madipakkam

    ReplyDelete
  57. Very informative blog. Thanks for sharing such good information and keep on updating.
    ISTQB Training in Chennai | ISTQB Training in Guindy

    ReplyDelete
  58. Very informative blog. Thanks for sharing such good information and keep on updating.
    Java Training in Chennai | Java Training in Chrompet

    ReplyDelete
  59. Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
    Graphic Designing Training in Chennai | Graphic Designing Training in Keelkattalai

    ReplyDelete
  60. Thanks its Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us.
    Ethical Hacking Training in Chennai | Ethical Hacking Training in Thiruvanmiyur

    ReplyDelete
  61. The provided information’s are very useful to me.Thanks for sharing.Keep updating your blog...
    Java Training in Chennai | Java Training in St.Thomas Mount

    ReplyDelete
  62. This is a nice post in an interesting line of content.Thanks for sharing this article.
    Java Training in Chennai | Java Training in Meenambakkam

    ReplyDelete