Update Scope
This commit is contained in:
BIN
img/referenz1.PNG
Normal file
BIN
img/referenz1.PNG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.1 KiB |
@ -5,3 +5,28 @@ url: https://git.haw-hamburg.de/pm1-tutorium/slides
|
|||||||
header: Programmieren 1 **Tutorium**
|
header: Programmieren 1 **Tutorium**
|
||||||
footer: Henri Burau und Eva Meinen
|
footer: Henri Burau und Eva Meinen
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
# Referenzvariablen
|
||||||
|
|
||||||
|
## Referenz- vs. Typvariablen
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```java
|
||||||
|
public class Person{
|
||||||
|
public int age;
|
||||||
|
public Person(int age) {age = age;}
|
||||||
|
}
|
||||||
|
|
||||||
|
Person Henri = new Person(0);
|
||||||
|
Person Eva = new Person(0);
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```java
|
||||||
|
boolean bool1 = Eva == Henri;
|
||||||
|
boolean bool2 = Eva.equals(Henri);
|
||||||
|
```
|
||||||
5
scope.md
5
scope.md
@ -6,11 +6,11 @@ header: Programmieren 1 **Tutorium**
|
|||||||
footer: Henri Burau und Eva Meinen
|
footer: Henri Burau und Eva Meinen
|
||||||
-->
|
-->
|
||||||
|
|
||||||
#scope
|
# scope
|
||||||
|
|
||||||
= Sichtbarkeit = Gültigkeitsbereich
|
= Sichtbarkeit = Gültigkeitsbereich
|
||||||
|
|
||||||
Bereich in dem auf die Variable zugegriffen werden kann
|
= Bereich in dem auf die Variable zugegriffen werden kann
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -18,6 +18,7 @@ Bereich in dem auf die Variable zugegriffen werden kann
|
|||||||
int zahl = 3;
|
int zahl = 3;
|
||||||
addierer(zahl);
|
addierer(zahl);
|
||||||
System.out.printf(zahl); // Konsolenausgabe?
|
System.out.printf(zahl); // Konsolenausgabe?
|
||||||
|
|
||||||
public void addierer(int zahl) {
|
public void addierer(int zahl) {
|
||||||
zahl++;
|
zahl++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user