Tag: Java Arrays

Core Java

Java Convert a List to Array And Vice-Versa

Introduction: In this article, we’ll quickly learn how to convert a Java List (say an ArrayList) to an array and vice-versa. If you wish to learn more about an ArrayList in general, feel free to read our article on Java ArrayLists. Meanwhile, let’s get going! Convert Java List to Array: Converting a Java List to an array is […]

Be the First to comment. Read More
Core Java

Check If Java Array Contains a Given Value

Introduction: In this quick tutorial, we’ll look at how to find if a Java array contains a given value. In other words, we’ll check if a given value is present in our Java array or not. Linear Search: One of the most straightforward approaches would be to linearly search our array to check if it […]

Be the First to comment. Read More
Core Java

Find Sum/Average In Java Array

Introduction: In this article, we’ll learn to find the sum and average of all elements in a given Java array. We’ll first cover the basic for loop-based approach and then extend our knowledge to achieve the same using Java Streams API. Finding Sum of Elements In Array: Let’s look at how we can find the […]

Be the First to comment. Read More
Core Java

Find Maximum/Minimum Element In Java Array

Introduction: In this quick tutorial, we’ll learn ways to find the maximum/minimum element in a Java array of primitives. We’ll start with the very basic algorithms and end up with a solution using Java 8 Streams API.   Approach 1:: Linear Search It is a pretty straightforward approach to find max/min elements in a given […]

One comment Read More