Apr 17

Write a java program to sort characters in String in java?

Steps to be followed to sort characters in string:

1)            Take  one string as input.

2)            convert first string to character array .

3)            Sort the characters in array using arrays.sort() method.

4)            Construct string by using sorted characted array. Continue reading

Apr 17

Write a java program to check two Strings are anagrams or not by sorting and comparing strings?

Java anagram program is very important program asked in java interview for freshers and experienced.

What are Anagrams?

Two Strings are anagrams if they contain same characters but in different order.

Here are the steps to be followed to check two Strings are anagrams or not :


1)      Take  two strings as input.

2)      convert two strings to character array .

3)      Sort two strings arrays.

4)      Compare two string arrays if they are equal they are anagrams otherwise they are not.

Continue reading

Apr 14

Write a java program to print multiplication table for given number?

This tutorial explains how to print multiplication table given a number as input.If we give input a 7 it should print multiplication table for 7.

Ex : The output should be displayed as





If we observe the above pattern logic will be very simple.7 is the input number and the value with which we are multiplying is getting incremented starting from 1.We can use any loop to increment the value.so in the complete program the main logic is the below line : Continue reading

Apr 13

write a program to find largest of three numbers in java?

This is one of the basic java program which helps us to understand the concepts of relational operators and conditional statements in java.

Steps to find largest of three numbers :

  1. Take three numbers from command line.
  2. store the numbers in three variables as x,y and z.
  3. compare each value with other two values. If the number is greater print the number as largest. Continue reading