Category: java

  • Java XOR (Exclusive or) operator on Booleans

    In this tutorial, will show how to use a the Java XOR (exclusive or) operator on booleans, and we will discuss how the operator behaves with various combinations of boolean values. In Java, booleans can hold only two values, true and false. The XOR operator in Java ‘ ^ ‘ can be used with booleans…

  • Java BigDecimal, Dealing with high precision calculations

    In this tutorial, we will discuss how to use the Java BigDecimal class to deal with calculations that require a high degree of precision, such as when dealing with currency conversion, taxes or even high accuracy mathematical calculations. Why do we need the BigDecimal class In Java a floating point or a fractional number can…

  • ArithmeticException in Java – Causes & Treatment

    In this tutorial, we will introduce a few examples that would highlight the causes of getting an ArithmeticException thrown within a Java program. We will discuss the common causes of the exception, and how these could be treated. What is an ArithmeticException? An arithmetic exception is an error that is thrown when an invalid arithmetic…

  • Java ArrayIndexOutOfBoundsException – Causes & Fixes

    In this tutorial, we will discuss what a Java ArrayIndexOutOfBoundsException is, what causes it and how to make sure that you avoid it. What is an ArrayIndexOutOfBoundsException An array-index out of bounds exception is a Java exception thrown due to the fact that the program is trying to access an element at a position that…

  • Getting started with Reactive Programming and Reactor Core

    Before getting into this tutorial, I recommend that you read our “Understanding reactive programming in Java” post, as it will lay down the foundation to what we will do in this tutorial and will make things a lot easier to understand. In this post, we will go through a sequence of steps that will allow…

  • Understanding reactive programming in Java

    In this post, we will discuss the principles of reactive programming, which problems is it trying to solve and discuss the basics of reactive programming in Java. This tutorial will focus on the usage of reactive programming in Java but the principles and ideas discussed in this tutorial can apply to other programming languages. This…

  • Configuring XStream to convert Java objects to and from XML

    Serializing Java objects to and from XML is a necessary operation in many software systems. For example, when communicating with other systems and back-ends, or simply when storing and loading data. In this tutorial, we will discuss how to use the XStream library to convert Java objects to and from XML. What is XStream XStream…

  • Java Switch Statements – Uses, Advantages and Restrictions

    In this tutorial, we will discuss what are Java switch statements, how to use them, the allowed data types that can be used in the switch statements and the advantages and restrictions that apply to them.   What is a “switch” statement   A “switch” statement in Java  is a conditional operator used to direct…

  • What is a BigInteger and how to use it in Java

    A BigInteger is a data structure in Java that is used to represent very large numerical values that would otherwise not fit within a primitive data type such as an int or long. In this post, we will discuss different ways to initialize a BigInteger and how to use it to perform mathematical operations. Why…

  • How to find prime numbers using Java

    In this post, we will discuss how to write a simple Java program to find prime numbers between 1 and 100. We will be using a simple algorithm implemented in nested loops. So let us get started! What is a prime number? A prime number is a number which can only be divided by 1…