November 1st, 2017

Java 101: Datastructures and algorithms in Java, Part 2

Core Java, Java App Dev, Java Language, Learn Java, others, Programing, by admin.

An array is a fundamental datastructure category, and a building block for more complex datastructures. In this second part of my Java 101 introduction to datastructures and algorithms, you will learn how arrays are understood and used in Java programming. I introduce the concept of an array and how arrays are represented in the Java language. Then you’ll learn about one-dimensional arrays and the three ways that you can introduce them to your Java programs. Finally, we’ll explore five algorithms used to search and sort one-dimensional arrays.

Note that this article builds on Datastructures and algorithms, Part 1, which introduces the theoretical side of datastructures and the algorithms associated with them. That article includes an in-depth discussion of algorithms and how to use space and time complexity factors to evaluate and select the most efficient algorithm for your Java program. This article will be much more hands-on, and assumes you have already read and digested Part 1.

What is an array?

An array is a sequence of elements where each element is associated with at least one index. An element is a group of memory locations that store a single data item. An index is a nonnegative integer, which in this case is used to uniquely identify an element. This relationship is similar to how a box number uniquely identifies a house on a given street.

The number of indexes associated with any element is the array’s dimension. In this article, we’ll be talking about one-dimensional arrays. The next article in this series introduces multi-dimensional arrays.

Back Top

Leave a Reply