3:50 pm - Wednesday February 19, 7642

Tag Archives: Java Example

Java Example Program to convert positive number to negative

/* java example program to convert -ve number to +ve number */ /** * @author:candidjava.com * @description: here, we are using Math.abs function to convert -ve number to * +ve number */ public class Convert { public...

Java Example Program to find Second Largest Number

/* Find Second Largest Nunber */ /** * @author:Candidjava.com * @Description:Find the second Largest Number */ public class FindsecLarg { public static void main(String[] args) { // intialize the array values int arr[] = {...

Java Example Program using while Loop

/*program for While Loop statement*/ /** * @author:candidjava.com * @description:Print the counts the number usinr while loop */ public class WhileLoopExample { public static void main(String args[]) { // initialize a variable int...

Java Example Program using for loop

/*program for for statements*/ /** * @author:candidjava.com * @description:Print the triangle values using for loop */ public class ForLoopExample { public static void main(String args[]) { // declare the variables int i, j; //...

Java Example Program using IF statement

/* Program for if statement */ /** * @author:Candidjava.com * @Description:Find the charges for current units using if statement */ public class Units { public static void main(String args[]) { int i = 1003, u; // check the...

Java Example Program for Hello World

//java example program for hello world /** @author:candidjava.com @description:java example program for hello world */ public class HelloWorld { public static void main(String args[]) { System.out.print("Hello world");//...

Java Example Program to Reverse the Number

//Java Example Program to Reverse the Number /** * @author:candidjava.com * @description:Program to Reverse the Number */ public class Reverse { public static void main(String args[]) { int b;// take a variable to perform Reverse...

Java Example Program to find the smallest of two numbers

//Java Example Program to find the smallest of two numbers /** * @author:candidjava.com * @description:Program to find the smallest of two numbers */ public class Smallest { public static void main(String args[]) { int a, b; a...

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 Subtraction

/*java program for subraction of two numbers*/ /** *@author:Candidjava.com *@Description:To calculate the subraction of a numbers */ public class Subraction { public static void main(String[] args) { int a=81; int b=45; int result=a-b;//use...

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 display Numbers from 1 to N using For Loop

/*program to print numbers from 1 to N*/ /** * @author:candidjava.com * @Description:here, we are using for loop to print numbrs from 1 to N */ class For { public static void main(String args[]) { int i = 1; int N = 15; for...

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

/*program to print numbers from 1 to N*/ /** * @author:candidjava.com * @Description:here, we are using do...while loop to print numbrs from 1 to N */ public class DeeDoWhile { public static void main(String args[]) { int i...

Java example program to swap numbers

/*program to swap the two given numbers*/ /** * @author:candidjava.com * @Description:swap the two given numbers */ public class SwapTwoNumbers { public static void main(String args[]) { int x = 25; int y = 52; System.out.println("Before...

Java Example Program using conditional operation

/*java example program using conditional operator */ /** * @Author:candidjava.com * @Description:program to find the largest number using conditional operator */ public class ConditionalOperator { public static void main(String...

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...