Introduction to Data Structure Types in Java

So far, in our online Progressive Java Course, we are declaring the types one by one, do you remember?
Maybe not, because it is something normal for you.

Imagine the following situation: you've been hired to create a Java application to a college, where there are more than 2 thousands students.
Among other things, you have to create types - float, probably - to store students' grades, integers to store the missed classes, strings for the names etc..

So, you will declare thousands of variables? One by one?
No! Learn data structure.

What Data Structures are in Java

One of the greatest utility in Java programs is be able to process large quantities of information.

Ever wondered how many floats, integers and strings are declared in the software of the USA government?
Millions? Of course not. Million is just the number of inhabitants.
Each resident has his name, ID, address, taxes, criminal record, health, employment etc etc..

Have you thought about how to handle all this?
Until now, in Progressive Java course, we were declaring variable by variable, one by one. Obviously in an application as a government it is impossible.

Incidentally, neither needs to be a government. Data from a midsize business already are large enough not to be possible to create each variable by hand.

For this, use special type of datas, the data structure, such as arrays (also known as vectors), ArrayLists, lists, stacks and queues.

Data Structures in Java: Array and ArrayList

In this sectio about data structure, we will give an introduction to such important tools to work with many data and information.

In a simple way, we can define the Array or ArrayList, and as a set of variables of the same type.
Learn about Array and ArrayList data structures in JavaInstead of declaring a brick at a time, we use arrays to declare a wall, with several blocks of the same bricks, just all once.
For example, instead of declaring several integers, one by one, until we declared 50 integer variables, we use Array to declare a block of 50 variables, all of the same type and numbered sequentially.

Array is simply this. A block of variables of the same type listed in sequence.
ArrayList Arrays are more potent, ie, they are arrays but with more utilities (and complexity).
We will not go into more details on Array and ArrayList right now, because this section is devoted to its study.

Let's talk a little about the other data structures, which will be addressed throughout the course, in other sections of the site:

Java data structure: List

Learn about List data structure in JavaImagine a list, any list. The phone book, for example.
It is a record data.
How it works? How do you use?

There is no right way to use. You can use the beginning of the list, the middle or end, and go back.
It is simply a list, a display of information at their disposal.
Thus it will be in Java.

Data Structures in Java: Queue

Imagine a bank queue.
Learn about Queue data structure in Java
How it works? (Actually, how it should work)
Anyway, as a 'list'?

Of course not. In the queue, whoever is in front is served first.
So this way will be in the Java programming data structure.

When your data is under this framework, the information that is in the head of the queue will be addressed first, as well as people who are at the head of a queue bank would be attended first.

Data structure in Java: Stack

Learn about Stack data structure in JavaNow imagine a stack of plates.
You ate a lasagna dish and kept the plate.
Then a pizza dish and kept it.
Finally, you ate a salad and put the dish in the stack, always at the top.

Now you have a line of dishes, which will lead to the sink to wash.
What dish will wash first? The first, the lasagne?
No! The last of the salad, which is at the top of the stack.

So it will be in your applications in Java: the information on cell structure, the latest information (last dish) that arrived - ie, the most recent will be the first to be treated (the first to be washed).
That is, is the opposite of the queues.
Here, the last arriving will be served.

In queues, the first arriving is that they are attended.

With this, you already have an idea about data structure in Java and that there are many ways to see and how to treat information.

No comments: