• 25 October

    Create Array from 1 to n in Java

    Introduction In this article, we will look at How to Create an Array from 1 to n in Java. We need to Initialize Arrays in a sequence of values ranging from 1 to number N. Knowing how we can initialize arrays in different ways will give us deeper insights into Array in Java and allow […]

  • 19 September

    How to Print 2D Array in Java

    Introduction In this article, we get a look on How to print a 2D or Two Dimensional array in java. Arrays are one of the most useful data structures when it comes to data storage. Arrays provide random access to the elements via their index basing which makes both accessing and storing the most efficient. […]

  • 19 September

    Return Empty Array in Java

    TL;DR To return empty Array in Java, you can use curly braces. [crayon-661e282ab5b3d997890424/] or [crayon-661e282ab5b45495990319/] 1. Introduction In this article, we will take a look on to How to return Empty array in java. We will look at different ways to achieve this with demonstrated working examples in detail. At first, let us have a […]

  • 16 September

    How to Write Array to File in Java

    In this post, we will see how to write array to file in java. Ways to Write Array to File in Java There are different ways to write array to file in java. Let’s go through them. Using BufferWriter Here are steps to write array to file in java: Create new FileWriter and wrap it […]

  • 17 May

    How to Initialize an Array with 0 in Java

    This article discusses the arrays and different ways to initialize an array with 0 in Java. Arrays The arrays are the fundamental data structures, they are sequences of elements stored in contiguous memory locations. The first step when using a data structure involves initializing the data structure which in our case is arrays. Array instantiation […]

  • Set an array to another array in java
    23 April

    Set an Array Equal to Another Array in Java

    This article discusses methods to set an array equal to another array in Java. Arrays are the most basic data structures that store the data at contiguous memory locations. The operations on the array elements are performed using the indices. Setting an Array Variable Equal to Another Array Variable It might seem logical to set […]

  • Check if array is empty in Java
    04 March

    Check if Array Is Empty in Java

    In this post, we will see how to check if array is empty in Java. The arrays are a data structure that facilitates storing multiple instances of data together in contiguous memory locations. This article discusses different cases when an array is considered to be empty in Java. It also discusses methods to check, for […]

  • Initialize empty array in java
    01 January

    Initialize Empty Array in Java

    💡 Outline You can use below code to initialize empty array in java. [crayon-661e282ab8184685555741/] Or [crayon-661e282ab818b620313139/] Or [crayon-661e282ab818c381026536/] 1. Introduction In this post, we take a look on How to Initialize empty array in Java. We will look at different ways to Initialize arrays in Java with dummy values or with prompted user inputs. Arrays […]

  • Write a Program to Find the Maximum Difference between Two Adjacent Numbers in an Array of Positive Integers
    07 April

    Write a Program to Find the Maximum Difference between Two Adjacent Numbers in an Array of Positive Integers

    In this article, we look at a problem : Given an Array of Positive Integers, Find the [Maximum Difference](https://java2blog.com/maximum-difference-between-two-elements-in-array/ "Maximum Difference") between Two Adjacent Numbers. For each pair of elements we need to compute their difference and find the Maximum value of all the differences in array. Let us look at an example, Consider this […]