Skip to content

Commit f81d502

Browse files
committed
corrections and doc
1 parent befe2d8 commit f81d502

File tree

2 files changed

+144
-1
lines changed

2 files changed

+144
-1
lines changed

docs/blog/posts/20245-03-13-2025-java-workshop.md

Lines changed: 144 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,21 @@ Before you get started, make sure you have the following installed on your compu
3434
* Docker Desktop [https://docs.docker.com/desktop/](https://docs.docker.com/desktop/)
3535
* Git [https://git-scm.com/downloads](https://git-scm.com/downloads)
3636
* VS Code [https://code.visualstudio.com/download](https://code.visualstudio.com/download)
37+
* Dev Container Extension [https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
3738

38-
## Getting Started
39+
## Workshop Structure
40+
41+
* Setup
42+
* Variables and Data Types
43+
* Operators
44+
* Input and Output
45+
* Conditional Statements
46+
* For Loops
47+
* Arrays
48+
* Functions
49+
* Practical Project Demo
50+
51+
## Setup
3952

4053
To get started, download the workshop materials by cloning the repository: (this can also be done from inside vscode)
4154

@@ -74,3 +87,133 @@ Once you've cloned the repository, and it's open in VS Code you should get a pop
7487

7588
![Reopen in Container](assets/images/2025/java-workshop/reopen-in-container.png)
7689

90+
This will start the development container and install all the necessary dependencies for the workshop including Java.
91+
92+
This may take a few minutes so have a chat with your fellow attendees while you wait.
93+
94+
When it's done you should see a terminal window with the Java version displayed.
95+
96+
![Java Version](assets/images/2025/java-workshop/vscode-open.png)
97+
98+
## Hello World
99+
100+
Let's start with the classic "Hello World" program. This program simply prints "Hello World" to the console.
101+
102+
```java title="org/progsoc/java2025/basics/HelloWorld.java"
103+
--8<-- "https://raw.githubusercontent.com/ProgSoc/Java2025/refs/heads/main/org/progsoc/java2025/basics/HelloWorld.java"
104+
```
105+
106+
107+
## Variables and Data Types
108+
109+
There are several different data types in Java, including `int`, `double`, `boolean`, and `String`. Each data type is used to store different types of values.
110+
111+
Typically you declare a variable by specifying the data type followed by the variable name. For example, to declare an integer variable called `age`, you would write `int age;`.
112+
113+
```java title="org/progsoc/java2025/basics/VariablesAndDataTypes.java"
114+
--8<-- "https://raw.githubusercontent.com/ProgSoc/Java2025/refs/heads/main/org/progsoc/java2025/basics/VariablesAndDataTypes.java"
115+
```
116+
117+
## Operators
118+
119+
Operators are used to perform operations on variables and values. Java has several different types of operators, including arithmetic, comparison, and logical operators. (e.g. `+`, `-`, `*`, `/`, `==`, `!=`, `&&`, `||`)
120+
121+
```java title="org/progsoc/java2025/basics/Operators.java"
122+
--8<-- "https://raw.githubusercontent.com/ProgSoc/Java2025/refs/heads/main/org/progsoc/java2025/basics/Operators.java"
123+
```
124+
125+
## Input and Output
126+
127+
When building a simple Java program, you may want to take input from the user and display output to the user. This can be done using the `Scanner` class for input and the `System.out.println()` method for output. (similar to `console.log` in JavaScript)
128+
129+
```java title="org/progsoc/java2025/basics/UserInput.java"
130+
--8<-- "https://raw.githubusercontent.com/ProgSoc/Java2025/refs/heads/main/org/progsoc/java2025/basics/UserInput.java"
131+
```
132+
133+
## Conditional Statements
134+
135+
Conditional statements are used to perform different actions based on different conditions. In Java, you can use `if`, `else if`, and `else` statements to control the flow of your program.
136+
137+
```java title="org/progsoc/java2025/basics/Conditionals.java"
138+
--8<-- "https://raw.githubusercontent.com/ProgSoc/Java2025/refs/heads/main/org/progsoc/java2025/basics/Conditionals.java"
139+
```
140+
141+
## Arrays
142+
143+
An array is a collection of variables of the same type. You can access the elements of an array using an index. The index starts at 0, so the first element of an array is at index 0, the second element is at index 1, and so on.
144+
145+
```java title="org/progsoc/java2025/basics/Arrays.java"
146+
--8<-- "https://raw.githubusercontent.com/ProgSoc/Java2025/refs/heads/main/org/progsoc/java2025/basics/Arrays.java"
147+
```
148+
149+
## Loops
150+
151+
If you want your program to repeat a block of code multiple times, you can use loops. Java has several different types of loops, including `while` loops and `for` loops which we'll cover below.
152+
153+
### While Loop
154+
155+
This is a basic example of a `while` loop. The loop will continue to run as long as the condition inside the parentheses is `true`. (which is always in this case)
156+
157+
```java title="org/progsoc/java2025/basics/WhileLoop.java"
158+
--8<-- "https://raw.githubusercontent.com/ProgSoc/Java2025/refs/heads/main/org/progsoc/java2025/basics/WhileLoop.java"
159+
```
160+
161+
### While Condition
162+
163+
Instead of using a constant condition, you can use a variable to control the loop. In this example, the loop will continue to run as long as the value of `i` is less than 5.
164+
165+
```java title="org/progsoc/java2025/basics/WhileCondition.java"
166+
--8<-- "https://raw.githubusercontent.com/ProgSoc/Java2025/refs/heads/main/org/progsoc/java2025/basics/WhileCondition.java"
167+
```
168+
169+
### For Loop
170+
171+
A `for` loop is used when you know how many times you want to repeat a block of code. The loop has three parts: the initialization, the condition, and the increment.
172+
173+
Each of these parts is separated by a semicolon. The initialization is executed once before the loop starts, the condition is checked before each iteration of the loop, and the increment is executed after each iteration of the loop.
174+
175+
```java title="org/progsoc/java2025/basics/ForLoop.java"
176+
--8<-- "https://raw.githubusercontent.com/ProgSoc/Java2025/refs/heads/main/org/progsoc/java2025/basics/ForLoop.java"
177+
```
178+
179+
### Over an Array
180+
181+
By combining a `for` loop with an array, you can iterate over each element in the array and perform an action on it.
182+
183+
```java title="org/progsoc/java2025/basics/ArrayLoop.java"
184+
--8<-- "https://raw.githubusercontent.com/ProgSoc/Java2025/refs/heads/main/org/progsoc/java2025/basics/ArrayLoop.java"
185+
```
186+
187+
## Functions (Methods)
188+
189+
A function is a block of code that performs a specific task. You can define a function to take input parameters and return a value. In Java, you define a function using the `public static` keywords followed by the return type, the function name, and the parameters.
190+
191+
```java title="org/progsoc/java2025/basics/Functions.java"
192+
--8<-- "https://raw.githubusercontent.com/ProgSoc/Java2025/refs/heads/main/org/progsoc/java2025/basics/Functions.java"
193+
```
194+
195+
## Practical Project Demo
196+
197+
### Guess Number
198+
199+
Now that you've learned the basics of Java programming, it's time to put your skills to the test with a practical project. In this demo, we'll build a simple number guessing game.
200+
201+
If you're ready, open the `GuessNumber.java` file and follow the instructions in the comments to complete the project.
202+
203+
```java title="org/progsoc/java2025/demos/GuessNumber.java"
204+
--8<-- "https://raw.githubusercontent.com/ProgSoc/Java2025/refs/heads/main/org/progsoc/java2025/demos/GuessNumber.java"
205+
```
206+
207+
### Rock Paper Scissors
208+
209+
Another fun project you can try is building a simple rock-paper-scissors game. Open the `RockPaperScissors.java` file and follow the instructions in the comments to complete the project.
210+
211+
```java title="org/progsoc/java2025/demos/RockPaperScissors.java"
212+
--8<-- "https://raw.githubusercontent.com/ProgSoc/Java2025/refs/heads/main/org/progsoc/java2025/demos/RockPaperScissors.java"
213+
```
214+
215+
## Conclusion
216+
217+
Congratulations on completing the 2025 Java Workshop! We hope you've learned a lot and had fun along the way. If you have any questions or feedback, feel free to reach out to us on Discord or GitHub.
218+
219+
81.3 KB
Loading

0 commit comments

Comments
 (0)