Category Archives: Java

Define Circle Class in Java with Radius and Area

Task: Define Circle Class in Java with Radius and Area How To Define Circle Class in Java First of all, let’s consider the specification of a Circle class: Write a Java Program to create a  class Circle with the following features: Fields of Circle Class 1. A field radius of type double 2. a constant… Read More: Define Circle Class in Java with Radius and Area »

Loading

Create a New Java Class Rectangle – Java Program

Create a new Java Class Rectangle – This Python Tutorial will explain the creation of a new Java class named Rectangle with the following class specification: How To Create a New Rectangle Class in Java Write a Java program using Objects and Classes concepts in Object Oriented Programming. Define the Rectangle class that will have: Two… Read More: Create a New Java Class Rectangle – Java Program »

Loading

Java Program Area of Triangle by Three Sides

Task: Write a Java Program Area of Triangle by Three Sides. The Source Code of Java Program Area of Triangle by Three Sides /* * Write a Java program to find the area of a triangle when lengths of three sides are given. */ package trianglearea; import java.util.Scanner; /** * @author www.EasyCodebook.com */ public class… Read More: Java Program Area of Triangle by Three Sides »

Loading

Fibonacci Program in Java to print n terms

Task: Write a Fibonacci Program in Java to print n terms of Fibonacci series. The user will input the number of Fibonacci terms to print, at run time. Use Scanner class of java.util to get input from user through key board. The Source code of Fibonacci Program in Java to print n terms   /*… Read More: Fibonacci Program in Java to print n terms »

Loading

Java Array Program Implement Linear Search Algorithm

Task: Write a Java Array Program Implement Linear Search Algorithm. Input 10 numbers in array. Input a number to search in the array. Find index of this item in array of 10 integers. The source code for Linear Search program using array in Java programming Language: /* * Write a Java program to Search an… Read More: Java Array Program Implement Linear Search Algorithm »

Loading

Java Array Program to Find Sum of Even Numbers in Array

Task: Write a Java Array Program to Find Sum of Even Numbers in Array. This Java program uses a simple mathematical logic to check whether an array item ( that is number ) is even. The idea is to divide a number by two and obtain remainder. If remainder is a zero then the given… Read More: Java Array Program to Find Sum of Even Numbers in… »

Loading

Java Array Program to Print Odd Numbers in Array

Task: Write a Java Array Program to Print Odd Numbers in Array. This Java Array program uses simple logic to check whether number is odd. It will divide a number with 2 and get remainder of division using % arithmetic operator. Therefore, if the remainder is a 1, the number will be odd. The Source… Read More: Java Array Program to Print Odd Numbers in Array »

Loading

Print List of Even Numbers in Java Array

Task: write a Java Array Program to Print List of Even Numbers in array. This Java program is written using: Java array – Declare array of 10 integer numbers. for loop – To input numbers in array and accessing these numbers. if statement in Java – To check a number for Even number. Source Code… Read More: Print List of Even Numbers in Java Array »

Loading

Find Sum and Average of Array in Java

Task: Write a Java program to Find Sum and Average of Array in Java. First of all, the user will input 5 numbers of type double in array. After this, the Java program will calculate sum and average of the numbers in array. The source code of Java Program to find Sum and average of… Read More: Find Sum and Average of Array in Java »

Loading

Java Arrays sort in Descending order

Task: How to use Java Arrays sort method for Descending order. How To Use Arrays.sort() method to Sort Arrays in Descending Order? In a previous post, we wrote a Java program to sort array in ascending order using Arrays.sort(array-name) method. We can use the following syntax to sort in descending order: Arrays.sort(array, Collections.reverseOrder()); Here we… Read More: Java Arrays sort in Descending order »

Loading