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
{{ message }}
This repository was archived by the owner on Nov 7, 2026. It is now read-only.
Repository navigation
Commit a075818
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@ The format is loosely inspired by Keep a Changelog.
15
15
16
16
### Added
17
17
18
+
-**Web 0.13.38, comments in Java:** lesson 6 has a new step „Kommentare im Code“ after „Jetzt in Java“: single-line `//` and multi-line `/* … */` comments, Java skips them and the structure chart stays the same; Javadoc `/** … */` is only mentioned. The IPO example (with „Im Editor öffnen“) shows the task in a multi-line comment, `// Eingabe`, `// Verarbeitung`, `// Ausgabe`, an explanation after a line, the expected output and a note for next time; plus a fill-in-the-gaps exercise, an Angeberwissen (PL/I 1964, BCPL 1967), a competence, a checklist line and two quiz questions. Lesson 14 marks closing brackets with `} // Ende if` / `} // Ende for`, lesson 20 the class frame with `} // Ende main` / `} // Ende Klasse`. New glossary entry Kommentar and Nachschlagen section „Java › Kommentare“ (de/en/pt).
18
19
-**Web 0.13.36, sequence diagram in lesson 5:** step „Schritt für Schritt“ now shows a sequence as a structure chart: four boxes one below the other (`laenge`, `breite`, `flaeche = laenge * breite`, output 15) with a short caption that each box runs exactly once from top to bottom (de/en/pt).
19
20
-**Web 0.13.35, open Java examples in the editor:** a Java example in a lesson can now carry the button „Im Editor öffnen“. It opens the example in a new tab with Programmieren set to Java, so students can run it, change values and try again; the structure chart builds itself from the code. Lesson 4 step „Text in Java“ (Mia, 14, 1.62) uses it and says how to try it (de/en/pt). For authors: write ```` ```java editor ```` instead of ```` ```java ````; a test checks that every such example parses without errors.
20
21
-**Web 0.13.32, every exercise says where to solve it:** below the title of each exercise card a small label names the area: „Löse diese Übung im Struktogramm.“ or, for `code: java` exercises, „Löse diese Übung in Programmieren.“ The area names are taken from the on-screen headings, so they always match (de/en/pt; applies to all VisuStruct, VisuBot and task-area exercises).
Copy file name to clipboardExpand all lines: web/lessons/de/06-eingabe-und-ausgabe.md
+85Lines changed: 85 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ kurz: Werte abfragen, Ergebnisse anzeigen und das EVA-Prinzip anwenden.
13
13
- ein Ergebnis zuerst ausrechnen und in einer Variablen speichern, dann diese Variable ausgeben, z. B. `int summe = a + b`, danach `output: summe`
14
14
- aus einem Aufgabentext Eingabe, Verarbeitung und Ausgabe herauslesen
15
15
- in Java mit dem Scanner Zahlen einlesen
16
+
- Kommentare mit `//` und `/* */` schreiben und damit meinen Code einteilen und erklären
16
17
:::
17
18
18
19
## Das EVA-Prinzip
@@ -168,6 +169,75 @@ tipp: `int jahre = scanner.nextInt();` liest ein. `int tage = jahre * 365;` rech
168
169
lösung: l06-java-tage-loesung.visustruct
169
170
:::
170
171
172
+
## Kommentare im Code
173
+
174
+
Im Code darfst du dir Notizen machen. Sie heißen **Kommentare** (englisch *comments*). Java überspringt sie beim Ausführen, das Programm und das Struktogramm bleiben also gleich. Es gibt zwei Arten:
175
+
176
+
-`//` macht den Rest der Zeile zum Kommentar. Das ist ein **einzeiliger Kommentar**.
177
+
-`/*` beginnt einen **mehrzeiligen Kommentar**, `*/` beendet ihn. Alles dazwischen gehört zum Kommentar, egal wie viele Zeilen. Die Sternchen am Anfang der Zeilen dazwischen braucht Java nicht, sie sehen nur ordentlich aus.
178
+
179
+
In fertigen Programmen siehst du manchmal auch `/** … */` mit zwei Sternchen am Anfang. Das ist ein **Javadoc-Kommentar**, aus dem Java eine Beschreibung des Programms erzeugen kann. Für dich reichen `//` und `/* */`.
180
+
181
+
So sieht das EVA-Beispiel mit Kommentaren aus:
182
+
183
+
```java editor
184
+
/*
185
+
* Aufgabe: Das Programm fragt nach zwei Zahlen
186
+
* und gibt ihre Summe aus.
187
+
*/
188
+
importjava.util.Scanner;
189
+
Scanner scanner =newScanner(System.in);
190
+
191
+
// Eingabe
192
+
System.out.println("Erste Zahl?");
193
+
int a = scanner.nextInt();
194
+
System.out.println("Zweite Zahl?");
195
+
int b = scanner.nextInt();
196
+
197
+
// Verarbeitung
198
+
int summe = a + b; // die beiden Zahlen addieren
199
+
200
+
// Ausgabe
201
+
System.out.println("Summe: "+ summe); // bei 3 und 4 erwarte ich: Summe: 7
202
+
203
+
// Nächstes Mal: auch Kommazahlen erlauben
204
+
```
205
+
206
+
Wofür Kommentare gut sind:
207
+
208
+
-**Aufgabenstellung:** Oben im mehrzeiligen Kommentar steht, was das Programm können soll.
209
+
-**Einteilung:**`// Eingabe`, `// Verarbeitung` und `// Ausgabe` teilen den Code nach dem EVA-Prinzip ein.
210
+
-**Erklärung:** Ein Kommentar hinter einer Zeile sagt, was dein Algorithmus dort macht.
211
+
-**Erwartung:** Schreib auf, welche Ausgabe du erwartest. Beim Testen vergleichst du dann.
212
+
-**Klammern zuordnen:** Später kommen Blöcke in geschweiften Klammern `{ }` dazu. Dann zeigt z. B. `} // Ende for`, welche Klammer was schließt.
213
+
-**Gedanken festhalten:** Woran musst du denken, wenn du nächstes Mal weiterarbeitest?
214
+
215
+
Klicke auf **Im Editor öffnen**, ändere einen Kommentar oder schreib einen neuen dazu. Das Struktogramm bleibt gleich, und VisuStruct behält deine Kommentare.
216
+
217
+
> Schreib nicht hinter jede Zeile einen Kommentar. Erkläre, was dein Algorithmus macht und warum, nicht jedes einzelne Zeichen.
218
+
219
+
::: angeberwissen
220
+
Beide Arten sind viel älter als Java: `/* … */` stammt aus der Sprache PL/I von 1964, `//` aus BCPL von 1967. Java hat sie über C und C++ geerbt.
221
+
:::
222
+
223
+
## Lückentext: Kommentare
224
+
225
+
::: lückentext
226
+
titel: Kommentare ergänzen
227
+
auftrag: Ergänze die Zeichen, damit oben ein mehrzeiliger Kommentar mit der Aufgabe steht und die anderen beiden Notizen einzeilige Kommentare sind.
228
+
```java
229
+
[[/*]]
230
+
* Aufgabe: Das Programm rechnet Euro in Cent um.
231
+
[[*/]]
232
+
int euro =3;
233
+
[[//]] Verarbeitung
234
+
int cent = euro *100;
235
+
[[//]] Ausgabe, erwartet: 300
236
+
System.out.println(cent);
237
+
```
238
+
erklärung: `/*` öffnet den mehrzeiligen Kommentar und `*/` schließt ihn. `//` gilt nur bis zum Ende der Zeile, darum braucht jede Notiz ihr eigenes `//`.
239
+
:::
240
+
171
241
## Lückentext: Eingabe
172
242
173
243
::: lückentext
@@ -283,6 +353,7 @@ Schätze dich bei jedem Punkt ehrlich ein: ☂️ noch nicht, ⛅ teilweise, ☀
283
353
- Ich kann ein Ergebnis zuerst ausrechnen und in einer Variablen speichern, dann diese Variable ausgeben, z. B. `int summe = a + b`, danach `output: summe`. → Vorsicht mit + in der Ausgabe
284
354
- Ich kann aus einem Aufgabentext Eingabe, Verarbeitung und Ausgabe herauslesen. → Vom Aufgabentext zum Struktogramm
285
355
- Ich kann in Java mit dem Scanner Zahlen einlesen. → Jetzt in Java
356
+
- Ich kann Kommentare mit `//` und `/* */` schreiben und damit meinen Code einteilen und erklären. → Kommentare im Code
286
357
:::
287
358
288
359
## Wissenstest
@@ -328,4 +399,18 @@ Schätze dich bei jedem Punkt ehrlich ein: ☂️ noch nicht, ⛅ teilweise, ☀
328
399
-[ ] Eine Kommazahl
329
400
-[ ] Einen ganzen Satz
330
401
> Für Kommazahlen gibt es `scanner.nextDouble()`, für ein Wort `scanner.next()`.
402
+
403
+
? Was macht Java mit einem Kommentar?
404
+
→ Kommentare im Code
405
+
-[ ] Es gibt ihn als Text aus.
406
+
-[x] Es überspringt ihn.
407
+
-[ ] Es meldet einen Fehler.
408
+
> Kommentare sind Notizen für Menschen. Das Programm läuft mit und ohne sie genau gleich.
409
+
410
+
? Wo endet ein Kommentar, der mit `/*` beginnt?
411
+
→ Kommentare im Code
412
+
-[x] Bei `*/`
413
+
-[ ] Am Ende der Zeile
414
+
-[ ] Bei der nächsten Leerzeile
415
+
> Darum kann ein Kommentar mit `/*` über mehrere Zeilen gehen. Ein Kommentar mit `//` endet dagegen am Zeilenende.
Copy file name to clipboardExpand all lines: web/lessons/de/14-verschachteln.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,13 +97,15 @@ int anzahl = 0;
97
97
for (int i =1; i <= n; i++) {
98
98
if (i %2==0) {
99
99
anzahl++;
100
-
}
101
-
}
100
+
}// Ende if
101
+
}// Ende for
102
102
System.out.println(anzahl);
103
103
```
104
104
105
105
Was im Struktogramm ineinander steckt, steht in Java in geschweiften Klammern ineinander. Jede Ebene ist vier Leerzeichen weiter eingerückt. Ist dein Code durcheinander, hilft der Knopf **Einrücken** oben im Bereich Programmieren.
106
106
107
+
Bei vielen schließenden Klammern `}` verliert man leicht den Überblick: Welche Klammer gehört zu welchem Block? Ein Kommentar dahinter sagt es dir, z. B. `} // Ende if` und `} // Ende for`. Das hilft dir auch, wenn du später weiterarbeitest.
108
+
107
109
`anzahl++` ist die Kurzform von `anzahl = anzahl + 1`.
Copy file name to clipboardExpand all lines: web/lessons/de/20-java.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,10 +98,12 @@ public class Einmaleins {
98
98
System.out.println("Welche Reihe?");
99
99
int zahl = scanner.nextInt();
100
100
...
101
-
}
102
-
}
101
+
} // Ende main
102
+
} // Ende Klasse
103
103
```
104
104
105
+
Die Kommentare `// Ende main` und `// Ende Klasse` hinter den letzten beiden Klammern sind nicht nötig, aber sehr hilfreich: So siehst du sofort, welche Klammer was schließt, und vergisst keine.
106
+
105
107
Der Name der Klasse kommt aus dem **Titel** des Diagramms. Die Datei muss genauso heißen, hier also `Einmaleins.java`. Das erledigt **Java speichern …** für dich.
106
108
107
109
> Der erzeugte Code ist ein guter Anfang, aber prüfe ihn. Legst du eine Variable zuerst an und liest sie später mit einer Eingabe neu ein, schreibt VisuStruct trotzdem `int pin = scanner.nextInt();`. Java meldet dann, dass es `pin` schon gibt. Lösche in dieser Zeile einfach das `int`.
Copy file name to clipboardExpand all lines: web/lessons/de/begriffe.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -193,5 +193,9 @@ Eine Variable, die direkt in der Klasse steht und nicht in einer Methode. Mit `s
193
193
### Scanner
194
194
Ein fertiger Baustein von Java, der Eingaben über die Tastatur liest, z. B. mit `scanner.nextInt()` eine Zahl. Er braucht ganz oben `import java.util.Scanner;`.
195
195
196
+
### Kommentar
197
+
auch: Kommentare, Kommentaren, Kommentars
198
+
Eine Notiz im Code für Menschen. Java überspringt sie beim Ausführen. `//` gilt bis zum Ende der Zeile, `/* … */` kann über mehrere Zeilen gehen.
199
+
196
200
### import
197
201
Eine Zeile ganz oben im Java-Code, die einen fertigen Baustein aus einem Paket holt, z. B. `import java.util.Scanner;`. Ohne sie kennt Java den Namen nicht.
Notizen im Code. Java überspringt sie, das Struktogramm bleibt gleich.
147
+
148
+
```java
149
+
/*
150
+
* Aufgabe: die Zahlen von 1 bis 10 addieren
151
+
* (mehrzeiliger Kommentar)
152
+
*/
153
+
// Verarbeitung (einzeiliger Kommentar)
154
+
int summe =0;
155
+
for (int i =1; i <=10; i++) {
156
+
summe = summe + i; // Kommentar hinter dem Code
157
+
} // Ende for
158
+
```
159
+
160
+
Gut für: die Aufgabenstellung, die Einteilung in Eingabe, Verarbeitung und Ausgabe, eine Erklärung, das Ende eines Blocks hinter `}`, die erwartete Ausgabe und Notizen fürs nächste Mal.
Copy file name to clipboardExpand all lines: web/lessons/en/06-eingabe-und-ausgabe.md
+85Lines changed: 85 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ kurz: Ask for values, show results and use the IPO model.
13
13
- work out a result first and store it in a variable, then output that variable, e.g. `int sum = a + b`, then `output: sum`
14
14
- pick out input, process and output from a task
15
15
- read numbers in Java with the scanner
16
+
- write comments with `//` and `/* */` and use them to structure and explain my code
16
17
:::
17
18
18
19
## The IPO model
@@ -168,6 +169,75 @@ tipp: `int years = scanner.nextInt();` reads. `int days = years * 365;` calculat
168
169
lösung: l06-java-tage-loesung.visustruct
169
170
:::
170
171
172
+
## Comments in code
173
+
174
+
You may write notes in your code. They are called **comments**. Java skips them when it runs, so the program and the structure chart stay the same. There are two kinds:
175
+
176
+
-`//` turns the rest of the line into a comment. This is a **single-line comment**.
177
+
-`/*` starts a **multi-line comment** and `*/` ends it. Everything in between belongs to the comment, however many lines. Java does not need the stars at the start of the lines in between, they just look tidy.
178
+
179
+
In finished programs you sometimes also see `/** … */` with two stars at the start. That is a **Javadoc comment**, from which Java can create a description of the program. For you, `//` and `/* */` are enough.
180
+
181
+
This is the IPO example with comments:
182
+
183
+
```java editor
184
+
/*
185
+
* Task: The program asks for two numbers
186
+
* and outputs their sum.
187
+
*/
188
+
importjava.util.Scanner;
189
+
Scanner scanner =newScanner(System.in);
190
+
191
+
// Input
192
+
System.out.println("First number?");
193
+
int a = scanner.nextInt();
194
+
System.out.println("Second number?");
195
+
int b = scanner.nextInt();
196
+
197
+
// Process
198
+
int sum = a + b; // add the two numbers
199
+
200
+
// Output
201
+
System.out.println("Sum: "+ sum); // for 3 and 4 I expect: Sum: 7
202
+
203
+
// Next time: allow decimal numbers too
204
+
```
205
+
206
+
What comments are good for:
207
+
208
+
-**The task:** the multi-line comment at the top says what the program should do.
209
+
-**Structure:**`// Input`, `// Process` and `// Output` divide the code by the IPO model.
210
+
-**Explanation:** a comment after a line says what your algorithm does there.
211
+
-**Expectation:** write down which output you expect. When you test, you compare.
212
+
-**Matching brackets:** later you will meet blocks in curly brackets `{ }`. Then, for example, `} // end for` shows which bracket closes what.
213
+
-**Keeping your thoughts:** what do you need to remember when you carry on next time?
214
+
215
+
Click **Open in editor**, change a comment or add a new one. The structure chart stays the same, and VisuStruct keeps your comments.
216
+
217
+
> Don't put a comment after every line. Explain what your algorithm does and why, not every single character.
218
+
219
+
::: angeberwissen
220
+
Both kinds are much older than Java: `/* … */` comes from the language PL/I from 1964, `//` from BCPL from 1967. Java inherited them via C and C++.
221
+
:::
222
+
223
+
## Fill in the gaps: comments
224
+
225
+
::: lückentext
226
+
titel: Add the comments
227
+
auftrag: Add the characters so that a multi-line comment with the task is at the top and the other two notes are single-line comments.
228
+
```java
229
+
[[/*]]
230
+
* Task: The program converts euros to cents.
231
+
[[*/]]
232
+
int euros =3;
233
+
[[//]] Process
234
+
int cents = euros *100;
235
+
[[//]] Output, expected: 300
236
+
System.out.println(cents);
237
+
```
238
+
erklärung: `/*` opens the multi-line comment and `*/` closes it. `//` only lasts until the end of the line, so every note needs its own `//`.
239
+
:::
240
+
171
241
## Fill in the gaps: input
172
242
173
243
::: lückentext
@@ -283,6 +353,7 @@ Rate yourself honestly for each point: ☂️ not yet, ⛅ partly, ☀️ I can
283
353
- I can work out a result first and store it in a variable, then output that variable, e.g. `int sum = a + b`, then `output: sum`. → Careful with + in an output
284
354
- I can pick out input, process and output from a task. → From the task to the structure chart
285
355
- I can read numbers in Java with the scanner. → Now in Java
356
+
- I can write comments with `//` and `/* */` and use them to structure and explain my code. → Comments in code
286
357
:::
287
358
288
359
## Quiz
@@ -328,4 +399,18 @@ Rate yourself honestly for each point: ☂️ not yet, ⛅ partly, ☀️ I can
328
399
-[ ] A decimal number
329
400
-[ ] A whole sentence
330
401
> For decimal numbers there is `scanner.nextDouble()`, for a word `scanner.next()`.
402
+
403
+
? What does Java do with a comment?
404
+
→ Comments in code
405
+
-[ ] It outputs it as text.
406
+
-[x] It skips it.
407
+
-[ ] It reports an error.
408
+
> Comments are notes for people. The program runs exactly the same with or without them.
409
+
410
+
? Where does a comment that starts with `/*` end?
411
+
→ Comments in code
412
+
-[x] At `*/`
413
+
-[ ] At the end of the line
414
+
-[ ] At the next empty line
415
+
> That is why a comment with `/*` can span several lines. A comment with `//`, on the other hand, ends at the end of the line.
Copy file name to clipboardExpand all lines: web/lessons/en/14-verschachteln.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,13 +97,15 @@ int count = 0;
97
97
for (int i =1; i <= n; i++) {
98
98
if (i %2==0) {
99
99
count++;
100
-
}
101
-
}
100
+
}// end if
101
+
}// end for
102
102
System.out.println(count);
103
103
```
104
104
105
105
What is nested in the structure chart is nested in curly brackets in Java. Every level is indented four spaces further. If your code gets messy, the **Indent** button at the top of the Programming area helps.
106
106
107
+
With many closing brackets `}` it is easy to lose track: which bracket belongs to which block? A comment after it tells you, for example `} // end if` and `} // end for`. This also helps when you carry on later.
Copy file name to clipboardExpand all lines: web/lessons/en/20-java.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,10 +98,12 @@ public class TimesTable {
98
98
System.out.println("Which times table?");
99
99
int number = scanner.nextInt();
100
100
...
101
-
}
102
-
}
101
+
} // end main
102
+
} // end class
103
103
```
104
104
105
+
The comments `// end main` and `// end class` after the last two brackets are not needed, but very helpful: you see at once which bracket closes what, and you don't forget one.
106
+
105
107
The name of the class comes from the **title** of the diagram. The file must have exactly the same name, so here `TimesTable.java`. **Save Java…** takes care of that for you.
106
108
107
109
> The generated code is a good start, but check it. If you first create a variable and later read it in again with an input, VisuStruct still writes `int pin = scanner.nextInt();`. Java then reports that `pin` already exists. Simply delete the `int` in that line.
Copy file name to clipboardExpand all lines: web/lessons/en/begriffe.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -198,5 +198,9 @@ An error that only happens while the program runs, for example an index outside
198
198
### Scanner
199
199
A ready-made Java building block that reads input from the keyboard, for example a number with `scanner.nextInt()`. It needs `import java.util.Scanner;` at the very top.
200
200
201
+
### comment
202
+
auch: comments, Comment, Comments
203
+
A note in the code for people. Java skips it when it runs. `//` lasts until the end of the line, `/* … */` can span several lines.
204
+
201
205
### import
202
206
A line at the very top of Java code that fetches a ready-made building block from a package, for example `import java.util.Scanner;`. Without it, Java doesn't know the name.
0 commit comments