Skip to content

Commit c7d5b3b

Browse files
authored
Update Data-Structures.md
1 parent 1c9c5a0 commit c7d5b3b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Notes/Data-Structures.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ Each element in the list is called a *node*, and contains two pieces of informat
3333
An example class for the **nodes** would look like the following:
3434

3535
```java
36-
class Node {
36+
class Node
37+
{
3738
String data;
3839
Node nextNode;
3940
}
@@ -46,7 +47,8 @@ The following code shows how to create a basic linked list (no data)
4647
```java
4748
Node start = new Node();
4849

49-
for (int i = 1; i <= 10; i++) {
50+
for (int i = 1; i <= 10; i++)
51+
{
5052
start.nextNode = new Node();
5153
start = start.nextNode;
5254
}
@@ -57,7 +59,8 @@ The following code shows how to iterate over a linked list
5759
```java
5860
Node start = ...
5961

60-
while (start != null) {
62+
while (start != null)
63+
{
6164
// do something with data from the node
6265
start = start.nextNode;
6366
}
@@ -104,7 +107,8 @@ set.add(4); // {7, 3, 4}
104107
The following is how you can iterate over each element in a set:
105108

106109
```java
107-
for (Integer i : set) {
110+
for (Integer i : set)
111+
{
108112
// do something with the element
109113
}
110114
```
@@ -197,7 +201,8 @@ map.put(17, "red");
197201
map.put(28, "blue");
198202
map.put(14, "green");
199203

200-
for (Integer key : map.keySet()) {
204+
for (Integer key : map.keySet())
205+
{
201206
System.out.print(key); // output is '14, 17, 28'
202207
}
203208
```

0 commit comments

Comments
 (0)