You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Java-Fundamentals/course/Basic-Syntax.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,9 +15,9 @@ public class Main {
15
15
Let's go through this line by line:
16
16
17
17
1.`public class Main { [...] }`
18
-
-In Java, every file contains one main *class* that has the same name as the file its in (in this case the above file would be called `Main.java`). We’ll talk about [classes](../../Object-Oriented-Programming/course/Classes.md) more in the future, but for now think of them as a container for parts of our code. Code between the opening and closing curly parenthesis is considered "part" of that class.
18
+
-You don't have to worry about this but in Java, every file contains one main *class* that has the same name as the file its in (in this case the above file would be called `Main.java`). We’ll talk about [classes](../../Object-Oriented-Programming/course/Classes.md) more in the future, but for now think of them as a *container* for parts of our code. Code between the opening and closing curly parenthesis is considered "part" of that class.
- This is the *main method* Every application in Java contains a main method. When we run our program, the java compiler starts running our code from here.
20
+
- This is the *main method* Every application in Java contains a main method. When we run our program, the java compiler *starts running our code from here*.
21
21
3.`System.out.println("hello World");`
22
22
- This is known as a **print statement**. It prints the text "Hello, World!" to standard output (your screen). The text inside the quotation marks is called a [String](./Variables.md#) in Java. We use `System.out.println(" [...]
23
23
")` to print the text inside the double quotes to the screen.
Copy file name to clipboardExpand all lines: src/Java-Fundamentals/course/Control-Flow.md
+14-12Lines changed: 14 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,26 @@
1
1
# Control Flow
2
-
Control flow is the way a program decides what to do and when. Generally, code is executed top to bottom, in the order of appearance, but control flow statements allows for branching and conditionally-executed code. can be modified using `functions`, `loops`, `if` / `else` statements, `jump` statements, and `try`/ `catch` blocks.
2
+
Control flow is the way a program decides what to do and when. Generally, *code is executed top to bottom*, in the order of appearance, but control flow statements allows for branching and conditionally-executed code. This can be done using `functions`, `loops`, `if` / `else` statements, `jump` statements, and `try`/ `catch` blocks. We will learn about a few of these later but for no here is an overview of what each is before we start learning about them.
3
3
4
4
<hr>
5
5
6
6
# Terminology
7
7
8
-
**Functions** : Allow for repeated portions of code to be executed differently each time based on a parameter
9
-
>`System.out.println("HELLO")` is a function that changes its execution based on the parameter passed, the string. We'll cover these more in depth later.
8
+
The following is stuff we haven't learned yet but will later!
10
9
11
-
**Loops** : Repeats a block of code several times, either in iteration, or while a condition is true.
10
+
-[**Functions**](./Functions.md) : Allow for repeated portions of code to be executed differently each time based on a parameter
11
+
>`System.out.println("HELLO")` is a function that changes its execution based on the parameter passed, the string. We'll cover these very soon!
12
+
13
+
-[**Loops**](./Loops.md) : Repeats a block of code several times, either in iteration, or while a condition is true.
12
14
>Imagine printing
13
15
>```python
14
16
>>>> Hello 1
15
17
>>>> Hello 2
16
18
>>>> Hello 3
17
19
>```
18
-
>with just a single block of code rather than 3 lines. Its more cleaner.
19
-
>They will be covered more in depth later.
20
+
>With just a single block of code that repeats rather than 3 lines.
21
+
>They will be covered soon as well.
20
22
21
-
**If/Else** statements : Let you branch between different executions of the same code based on a condition.
23
+
- [**If/Else**](./If-Else.md) statements : Let you branch between different executions of the same code based on a condition.
22
24
>Like a human, we conditionally behave as well.
23
25
>```
24
26
>If hungry, Then Eat().
@@ -31,7 +33,7 @@ Control flow is the way a program decides what to do and when. Generally, code i
31
33
## Jump Statements
32
34
These statements move the "flow" of execution of code. Instead of the code running in a straight line down the file, jump statements move around where the execution occurs in the code.
33
35
34
-
```break``` : Stops a flow early
36
+
-```break``` : Stops a flow early
35
37
```java
36
38
for (int i = 0; i <10; i++) {
37
39
if (i ==3) break;
@@ -45,7 +47,7 @@ for (int i = 0; i < 10; i++) {
45
47
>>>>2
46
48
>```
47
49
48
-
```continue``` : Skips the current iteration:
50
+
-```continue``` : Skips the current iteration:
49
51
50
52
```java
51
53
for (int i = 0; i <5; i++) {
@@ -61,7 +63,7 @@ for (int i = 0; i < 5; i++) {
61
63
>>>>4
62
64
>```
63
65
64
-
Switch Cases:
66
+
-Switch Cases:
65
67
To chose between many options of a variable, and a cleaner than chaining ```ifelse``` statements.
66
68
```java
67
69
String day = "Tuesday";
@@ -85,7 +87,7 @@ switch (day) {
85
87
>>>> Second day of the week
86
88
>```
87
89
88
-
```Return ``` : End a function or execution of a loop, and output a value from the call
90
+
-```Return ``` : End a function or execution of a loop, and output a value from the call
Without the try catch block, if the ArithmeticException went to Java, then the rest of any code following would not execute (see the print statement after not present in the terminal output).
137
+
Without the try catch block, if the ArithmeticException went to Java, then the rest of any code following would not execute (see the print statement after not present in the terminal output). more
Copy file name to clipboardExpand all lines: src/Java-Fundamentals/course/If-Else.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Java Branching: If, Else, Elif
1
+
# Java Branching: If, Else, & Else if
2
2
This page is a continuation to the explanation of [control flow](./Control-Flow.md). `If` and `else` statements let your program conditionally execute particular blocks of code.
0 commit comments