Task-2-Data-Structures

coding-tasks-awesometeam created by GitHub Classroom

Task-2-Data-Structures

intermediate Level
See Home Page
See Task 1 Page
See Task 3 Page
See Information Page

Task Information and Instructions

There are four files in this task: ArrayExample, ComicBooks, HashMapExercise, and ListExample. It shows basic functions on how to add more values, and how to create them. The purpose of this task is to show how data structures are used. A variable is a container to hold a value that can change. A data structure like an array can hold muliple variables.

Two coding tasks have been given: HashMapExercise, and ComicBook. Comic book uses a hash map to store ‘quality’ with a ‘price’ as key-value pairs.It also uses an enumeration which are like constants.

Remember to save your work and to check the feedback provided under this document.

Keywords

Match the keywords with the definitions: (copy and paste)

Predict the output

int[] myNum = {10, 20, 30, 40};
System.out.println(myNum[1]);
int[][] myNumbers = { {1, 2, 3, 4}, {5, 6, 7} }; //2D array
int x = myNumbers[1][2];
System.out.println(x);
ArrayList<Integer> myNum = new ArrayList<>();
myNum.add(20);
myNum.add(10);
myNum.add(40);
myNum.add(30);
Collections.sort(myNum);
System.out.println(myNum.get(3));

Introductory Steps:

HashMapExercise.java Steps:

Optional: ComicBooks.java

Not currently marked

Tips/Hints

If you are ever stuck, ask a friend and look at the examples. While they may be different data structures they handle data very similarly. Look at w3schools too.

Questions to think about:

Save your work


Hash Map Task status:

See report on Hash Map Task

Answers are in the ‘answer’ branch.