##### Java program to display Fibonacci series using for loop

In this tutorial, you will learn how to display the Fibonacci series in Java using the “for loop.” The Fibonacci series is a series of integers where the next number is the sum of the previous two numbers. The first 2 number of the series are 0 and 1. Display Fibonacci series in Java using ‘for... » read more

##### Convert a Stream to Array using Java 8

In the code below converts a Stream to an Array with Java 8. The Java 8 Library contains the .toArray() function that makes it easier to convert Datatypes to an array type. Convert a stream to an Array in Java import java.util.Arrays; public class Main { public static void main(String[] args) { String str =... » read more

##### Print Binary Equivalent of an Integer using Recursion in Java

When the numbers are represented in base 2, those are called binary numbers. From this article, we are going to convert the integer numbers to the binary format using a recursive function. Let’s take an example and see how this conversion takes place. Consider an integer number 23 = 16 + 4 + 2 +... » read more

##### Count the Number of Bits Set to One using Java

In this article, we’ll be counting the number of bits set to one using Java. To make it more transparent, let’s take number 6 as an example. Number 6 is represented as 110 in binary. From our example, the output is 2, as there are two ones in the binary of the converted number. In... » read more

##### Convert Integer Values to Byte, Character, and Float using Java

In Java, just like most programming languages, we can convert one data type into another type using Type Conversion. Mainly, there are two types of conversions, and in this example, we’ll be using both of them. First one is automatic type conversion, which automatically converts compatible data types into another type using Java — for... » read more

##### Find Sum of N Numbers Using Recursion in Java

In this article, you’ll learn how to get the sum of n numbers using a recursion function. Recursion function is said to be calling itself over and over again in the application. By using recursive functions, we can remove the side effects of the looping structures. It is essential to define the base case or... » read more

##### Check if a Given Integer is odd or even using Java

In java programming, it is easy to find whether the number is odd or even using a single function. The logic behind the function is to identify whether the input number is divisible by two without any remainder. If so, that integer is considered to be an even number. Odd or Even Checker using Java... » read more

##### Convert int to BigInteger in Java

The code below is to convert int to an integer, as well as an integer to a BigInteger. This example uses the namespace java.math. import java.math.BigInteger; public class IntConvertor{ public static void main(String[] args) { int input = 10; //Print out System.out.println(input); // convert int to Integer Integer integer = Integer.valueOf(input); //Print out System.out.println(integer); // convert... » read more