12:54 pm - Wednesday February 22, 2017

Archive: Sample Programs in java Subscribe to Sample Programs in java

Java Example Program for delete duplicate element in an array

public class Task { /** * @ author:Candid @ description:Java Program to delete Duplicate elements * in an array */ public static void main(String args[]) { int array[] = { 10, 20, 30, 20, 40, 40, 50, 60, 70,...

Java Example Program for inverse matrix

public class Matrix { public static void main(String[] args) { // array creation and allocated memory int[][] array = new int[3][3]; // to initialize the values array[0][0] = 1; array[0][1] = 2; array[0][2]...

Java Example Program for delete element in array

public class DeleteArray { /** * @Author:candid * @Description:To Delete a element in an Array */ public static void main(String[] arguments) { // internalize the array int arg[] = { 5, 6, 8, 9, 10 }; // Delete the Array Element...

Java Example Program for largest and smaller number in array

public class Array { /** * @ author: Candid @ Description: write a java program to find largest & * smallest number in an array */ public static void main(String[] args) { int a[] = new int[] { 5, 23, 45, 75, 10, 50, 7 }; int...

Java program for daemon thread

package Debug; public class DaemonThread extends Thread { /** * @author: candid * @description: java program for daemon thread. */ DaemonThread() { setDaemon(true); } public void run() { System.out.println("Is this thread Daemon?...

Java Program for Upper Triangular Matrix

public class MainUTM { public static void main(String[] args) { int[][] a = new int[3][3]; // declaration of an array. here array a // contain 3-rows and 3-columns. a[0][0] = 5; // here initializing 1st element of an array a[0][1]...

Java Example Program for lower triangular matrix

  public class MainLTM { public static void main(String args[]) { int[][] a = new int[3][3]; // declaration of an array. here array a // contain 3-rows and 3-columns. a[0][0] = 1; // here initializing 1st element of an array a[0][1]...

Java Example Program for Division

/*java program for Division of a number*/ /** *@author:Candidjava.com *@Description:To calculate the Division of two number using Division operator */ public class Div { public static void main(String[] args) { int a=20; int b=10; int...

Java Example Program for Multiplication

/*java program for multiplication of a numbers*/ /** *@author:Candidjava.com *@Description:To calculate the multiples of two number using muliple operator */ public class Mul { public static void main(String[] args) { int a=12; int...

Java Example Program to explain Pass By value to a method

/* Program for pass by value*/ /** *@author:Candidjava.com *@Description: passing values to method */ public class form { String name; int age; String gender; int exp; int sal; void setData(String n,int a,String g,int e,int s) { name=n; age=a; gender=g; exp=e; sal=s; } void...

Java Example Program to compute Area of Triangle

/*To find the area of triangle*/ /** *@author:Candidjava.com *@Description:To calculate area of trianlge */ public class Area { public static void main(String[] args) { int area; int breath=12; int height=20; area=(breath*height)/2;//...

Java Example Program to calculate grade using Switch Case

/** @author:candidjava.com @description:Program to calculate grade using Switch Case */ public class Findgrade { public static void main(String org[]) { int i = 2;// given input grade switch (i) { case 1: System.out.println("1st...

Java Example Program to display Numbers from 1 to N using While Loop

/** @author:candidjava.com @description:Program to display Numbers from 1 to N using While Loop */ public class displaynumbers { public static void main(String org[]) { int i = 1; int N = 10;// take variable N value is 10 while...

Java Example Program to find the Average of Marks

/** *@author:Candidjava.com *@Discription: collact the student marks and find the average of marks */ public class Avg { public static void main(String[] args) { int n = 5; int marks[] = { 50, 62, 75, 63, 92 };// student marks int...

Java Example Program to find the sum of first N Numbers

/** *@author:Candidjava.com *@discription: sum of first N numbers */ public class Sum { public static void main(String[] args) { int n = 10; int sum = 0; n = n * (n + 1) / 2;// calculate the sum N number for (int i = 0; i...

Java example program to display odd numbers between 1 to 100

/** @author:candidjava.com @description:program to display odd numbers between 1 to 100 */ public class odd { public static void main(String org[]) { int i; for(i=1;i<=100;i++){//loop for take 1 to 100 numbers if(i%2!=0)//condition...

Java example program to count number of odd numbers between 1 to 100

/* Program for odd numbers*/ /** *@author:Candidjava.com *@Description: To check a given number is Odd */ public class Odd { public static void main(String[] args) { int count = 0; int n; for (int i = 1; i <= 100; i++)...

Java example program to check whether the number is odd or even

/*program to find whether the given number is odd or even*/ /** @author:candidjava.com @Description: check the given number to know whether it is odd or even */ public class Evenodd { public static void main(String args[]) { int...

Java Example Program to swap numbers without using third or temp variable

/* java program for swapping of two numbers without using third variable*/ /** *@author:Candidjava.com *@Descripton:swapping of two numbers without third variable */ public class Swap { public static void main(String[] args) { int...

Java Example Program for fibonacci series

/* java program for Fibnacci series*/ /** *@author:Candidjava.com *@Description:Program for find the Fibonacci series of a given number */ public class Fibonacci { public static void main(String[] args) { int n; int c = 0; int...