Area of a Circle in Java

/*Calculate  Area Of a Circle in Java Example*/ import; import; import; class cir{ public static void main(String[] args) { int radius = 0; System.out.println(“Please enter radius of a circle”); try { //get the radius from console BufferedReader br = new BufferedReader(new InputStreamReader(; radius = Integer.parseInt(br.readLine()); } //if invalid value was entered catch(NumberFormatException […] Continue reading →

Swap number in Java

/* Swap Numbers Java Example*/ import*; class sw{ public static void main(String[] args) { int num1 = 10; int num2 = 20; System.out.println(“Before Swapping”); System.out.println(“Value of num1 is :” + num1); System.out.println(“Value of num2 is :” +num2); //swap the value swap(num1, num2); } private static void swap(int num1, int num2) { int temp = […] Continue reading →

Reverse digits in Java

/* Reverse Number using Java*/   import*; public class reverse { public static void main(String[] args) { //original number int number = 3456; int reversedNumber = 0; int temp = 0; while(number > 0)    {        //use modulus operator to strip off the last digit temp = number%10;    //create the reversed number […] Continue reading →

Finding HCF and LCM of Two Numbers In Java

Write a program to LCM and HCF of two integers.   import*; class HCM { int a,b,num,hcd,hcm; void lcm() { a=Integer.parseInt(System.console().readLine(“enter the first no.=”)); b=Integer.parseInt(System.console().readLine(“enter the 2nd   no.=”)); int m=a*b; if(a>b) { num=a; } else { num=b; } for (int i = 1; i <= num; i++) { if ((a%i==0) && (b%i==0)) { hcd=i; […] Continue reading →

Fibonacci Series In Java

Fibonacci series in Java In fibonacci series, next number is the sum of previous two numbers for example 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 etc. The first two numbers of fibonacci series are 0 and 1.Let’s see the fibonacci series program in java         import*; class FibonacciExample […] Continue reading →

Palindrome Strings in Java

     Palindrome Strings in Java:   Exapmle of Palindrome Strings are Liril, Radar, Level, Mom, Dad, Malayalam, Civic, Madam, Bob, Pop, Refer, Rotator, Stats.     Example Java Program to check whether a given number or string is palindrome or not import java.util.*; public class PalindromeSt { public static void main(String[] args) { Scanner […] Continue reading →

Palindrome Number In Java

      Palindrome number in java:       A palindrome number is a number that is same after reverse. For example 545, 151, 34543, 343, 171, 48984 are the palindrome numbers.When we reverse 545 same after reverse 545.           import*; import java.util.*; class Palindrome { public static void […] Continue reading →