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 »

Loading

Java Arrays sort Method to Sort Arrays

Task: Write a Java Program to use Java Arrays sort Method to Sort Arrays in Ascending Order. Use arrays containing of different types of data that is arrays of integers, arrays of doubles or arrays of strings strings etc. What is Java Arrays sort Method? Actually there is a class in java.util package known as… Read More »

Loading

Java Program For Input Numbers in Array

Task: Java Program For Input Numbers in Array and display them. The source code for  Java program to declare and enter numbers in array, and display them using for loop /* * Write a Java program to declare one dimentionalarray of 10 integers. Input numbers using for loop and display them. */ package inputnumbersarray; import… Read More »

Loading

Java Program to Count Digits of Number Using While Loop

Task: Write a Java Program to Count Digits of Number The source of Java Program to Count digits of a number input by the user at run time is: /* * Write a Java program to input a number and count its digit */ package countdigits; /** * @author www.EasyCodeBook.com */ import java.util.Scanner; public class… Read More »

Loading

Using Recursion in Java Find Factorial of Number

Task: Write a program Using Recursion in Java Find Factorial of Number. The source code of Java program to find factorial of a given number using recursion is: /* Write a Java program to calculate factorial of a number. Use a recursive method. */ package recursivefactorial; /** * @author www.EasyCodeBook.com */ import java.util.Scanner; public class… Read More »

Loading

Recursion in Java Explained With Examples

Java Programming Tutorial: Recursion in Java With Examples of Recursive Methods What is Recursion? Recursion may be defined as, “the process of invoking (and restarting) the same method that is currently executing is called Recursion”. Another Definition of Recursion – Recursion in Java A programming technique in which a method calls it self is known… Read More »

Loading

Java Program To Check a Number is Even or Odd

Task: Write a Java Program To Check a Number is Even or Odd The Source Code for Even Odd Checking Java Program /* Write a Java Program for checking a number is even or odd */ package evenodd; /** * @author www.EasyCodeBook.com */ import java.util.Scanner; public class EvenOdd { public static void main(String[] args) {… Read More »

Loading