JavaDevNotes.com

Java Int Array Examples

When we are dealing with small number of data, we can use a variable for each data we need to monitor. If we don't know how much data we need to process, or if the data is large, an array is very useful. A Java Integer Array is a an array object that holds multiple Integer values, if we need many int values in our computation. Below are some examples on how to use int array in Java.

Java Print Array Examples

Arrays are usually useful when working with arbitrarily large number of data having the same type. It is usually convenient if we can print the contents of an array. Below are some examples on how to print the contents of an Array in Java.

Java Initialize Array Examples

An array is a type of variable that can hold multiple values of similar data type. This is very useful for storing values when we don't know how many of them is needed, or when the number of values is very large. The first thing we need to know is how to initialize a Java Array. Below are some code samples on how to perform Java Array Initialization.

Java Array Length Examples

An Array in Java can hold arbitrary number of elements, depending on how the array object was created. To perform operations on array, it is fundamental to know it's length. For example, if we wish to iterate to all the values in the array, the length of the Java array will determine how many times we need to loop. This post will show how to get the Java Array's length and show examples on how to use the value.

Check If Java Array Contains A Certain Value

Arrays are very easy to use to hold large amount of values or Object instances. But a common problem is checking if a given array contains a specific value. There are several ways of doing this, some are efficient and some are not. Below are some examples on how to test if a Java array contains a certain value.

Java Sort Array Examples

An array is a common data structure in many languages. It is simple and easy to understand, hence it is commonly used in many situations. However, it is very common requirement to sort a an array or a collection of objects to ensure elements are in specific order (E.g. increasing order of value). If you need to learn how to perform this operation, below are some examples on how to Sort an Array in Java.

Java List to Array Examples

Although a List is a more powerful than an array, there are cases where we wish to convert the former to the latter's data structure. For example, if there is an existing API where the expected parameter is an Array, but what you have is a List. If you find yourself on such situations, here are some ways that can help you on how to convert a Java list to array.

Java Array to List Examples

Sometimes it is needed to convert a Java array to List or Collection because the latter is a more powerful data structure - A java.util.List have many functionality that ordinary array do not support. For example, we can easily check if a List ...

Java Array To String

Java objects have the toString() method to convert the instance to it's String representation. If you will try to invoke the toString() method of an Array, the result will be some weird String like [I@70f9f9d8. This does not seems logical, say for example you wish to write the String to logs. It is more useful to convert a Java Array to a String that gives human understandable results. Below are some examples on how to do that.

Java String Array Examples

A Java String Array is an object that holds a fixed number of String values. Arrays in general is a very useful and important data structure that can help solve many types of problems. It's simplicity on how to access contents through index makes it powerful yet user-friendly. Here are some examples on how to use String Array in Java.