Java Program to Swap Two Numbers

Here you will get java program to swap numbers using temporary variable. It can be done in following way. temp = a a = b b = temp Also Read: Java Program to Swap Two Numbers Without Using Third Variable

  Output Enter first number: 5 Enter second number: 8 Before swap: a = 5 b = 8 After swap: a = 8 b = 5

Read more

Java Program for Addition of Two Numbers

Here you will get java program for addition of two numbers. It is the very basic java program that is useful for beginners.

  Output Enter first number: 8 Enter second number: 4 Sum = 12

Read more

Java Program to Calculate Compound Interest

Here you will get java program to calculate compound interest. We can calculate compound interest by following formula. Compound Interest = Principle * (1 + Rate / 100) time Also Read: Java Program to Calculate Simple Interest

  Output Enter principle: 1000 Enter rate: 4 Enter time: 10 Compound Interest = 1480.2442849183444

Read more

Java Program to Calculate Simple Interest

Here you will get java program to calculate simple interest. We can calculate simple interest in java by using following formula. Simple Interest = (Principle x Rate x Time) / 100 Also Read: Java Program to Calculate Compound Interest

  Output Enter principle: 1000 Enter rate: 3 Enter time: 2 Simple Interest = 60.0

Read more

4 Ways to Calculate Power of Number in Java

Here I have shared the 4 different ways to calculate power of number in Java. Using Loop Using Recursion Using Math.pow() Using BigInteger.pow() 4 Ways to Calculate Power of Number in Java 1. Using Loop We can calculate the power of number by repeatedly multiplying the number by itself in a loop. This method works only for positive integer power.

  Output Enter a number and its power: 3 3 27   2. Using Recursion Recursion can also be

Read more

Program for Armstrong Number in Java

Here you will get program for armstrong number in java. A number which is equal to the sum of its digits raised to the power n is called armstrong number. Here n is the total digits in the given number. Example: 9 is an armstrong number as n = 1 and 91 = 9. 153 is an armstrong number as n = 3 and 13 + 53 + 33 = 1 + 125 + 27 = 153. Program for Armstrong Number in Java

Read more

Java Virtual Machine (JVM) Architecture

In this tutorial you will learn about Java Virtual Machine (JVM) architecture. What is JVM? Java Virtual Machine (JVM) is software or a virtual machine that takes .class file as an input and runs java bytecode. Java is machine independent but JVM is machine dependent.   What is Bytecode? When java program is compiled using javac compiler, it is converted into intermediate code known as bytecode. The byte code is stored in .class file. Bytecode contains special instructions that are

Read more

Different Ways to Take Input from User in Java

There are mainly five different ways to take input from user in java using keyboard. 1. Command Line Arguments 2. BufferedReader and InputStreamReader Class 3. DataInputStream Class 4. Console Class 5. Scanner Class   Below I have shared example for each of them.     How to Take Input from User in Java Command Line Arguments It is one of the simplest way to read values from user. It will work only when you are running the program from command

Read more
1 2 3 4 5