Data Structures

Learn to create, manipulate, and store information in data structures.

Start[missing "en.views.course_landing_page.learn-java.course_illustration" translation]
Data Structures
Lesson 1 of 1
  1. 1

    In the previous lesson, you learned a few of the object-oriented programming concepts used in Java: classes, objects, methods, and inheritance. In this lesson, you will learn how to use some of the...

  2. 2

    When you provide a set of instructions in a method, you might find that a common task is to manipulate an entire set of data. Java conveniently provides control statements to run a task repeatedl...

  3. 3

    Fantastic! For loops will be useful when reading and manipulating Java data structures. Let's talk about a few data structures that are built into Java. The first data structure we will explore is ...

  4. 4

    You created an ArrayList in the last exercise to store temperature data, but it does not contain any values yet. Let's add some values of type [...] to the ArrayList, one by one, like this: [....

  5. 5

    Great! Now we can start accessing the temperatures that our ArrayList stores. We can access the elements of [...] by using an element's index, or position, in the list. An element's index ...

  6. 6

    We can also insert new elements into an ArrayList. To insert new elements into an ArrayList, we can use a slightly different version of the [...] method that you previously used: [...] The e...

  7. 7

    Earlier in this lesson, we learned about the for loop. Since we've also learned how to retrieve the value at a specific index of an ArrayList, we can now access each of the elements. [...] In t...

  8. 8

    Since most for loops are very similar, Java provides a shortcut to reduce the amount of code required to write the loop called the for each loop. Here is an example of the concise *for each loop...

  9. 9

    Great! Another useful built-in data structure in Java is the HashMap. Although the name of the data structure might not make sense to you immediately, think of it as a real-life dictionary. A di...

  10. 10

    Perfect! Now let's fill the HashMap with useful data. Add keys and values to a HashMap: [...] In the example above, we used the [...] method to add a [...] key and an associated [...] va...

  11. 11

    To access data in an ArrayList, we specified the index. In order to access a value in a HashMap, we specify the key: [...] In the example above, we call the [...] method on the [...] HashMa...

  12. 12

    We can also access properties of a HashMap, such as the number of entries or the contents of the HashMap. Let's access the length and print out the contents of the [...] : [...] In the exampl...

  13. 13

    Great work! What did we learn so far? - For Loops: used to repeatedly run a block of code - For Each Loops: a concise version of a for loop - ArrayList: stores a list of data - HashMap: st...

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo

Data Structures

Start[missing "en.views.course_landing_page.learn-java.course_illustration" translation]