Constructing the Java Data Structure Certain data structures in Java can be created by you (yes you). In this example, we’ll go ahead and create an ArrayList data structure that has some of the methods that the built-in ArrayList class has. We’ll create 2 constructors: The default constructor that creates an ArrayList with a default size of 10. Constructor that allows an initial size to be passed to the array. We’ll also create a number of methods: void add(Object x); A method that allows you to place an Object at the end of the ArrayList. void add(int index, Object x); A method that allows
Category: Data Structures
Java’s Data Structure Illustrated One way to get exposure to a specific data structure is to simply read the documentation. But it won’t sink in thoroughly until you create your own example. In this article, we’ll look at the LinkedList class. The phone directory seems to be the example of choice by most college professors to introduce this data structure. Within our phone directory program, we’ll want to be able to: add a new record, delete the current record, change the first name of the current record, change the last name of the current record, change the phone number of the current record,