Merge branch 'master' of git.haw-hamburg.de:pm1-tutorium/slides
This commit is contained in:
commit
6fc4bdee43
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 8.7 KiB |
|
@ -5,3 +5,30 @@ url: https://git.haw-hamburg.de/pm1-tutorium/slides
|
|||
header: Programmieren 1 **Tutorium**
|
||||
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);
|
||||
```
|
||||
|
||||

|
51
scope.md
51
scope.md
|
@ -6,4 +6,55 @@ header: Programmieren 1 **Tutorium**
|
|||
footer: Henri Burau und Eva Meinen
|
||||
-->
|
||||
|
||||
# scope
|
||||
|
||||
= Sichtbarkeit = Gültigkeitsbereich
|
||||
|
||||
= Bereich in dem auf die Variable zugegriffen werden kann
|
||||
|
||||
---
|
||||
|
||||
```java
|
||||
int zahl = 3;
|
||||
addierer(zahl);
|
||||
System.out.printf(zahl); // Konsolenausgabe?
|
||||
|
||||
public void addierer(int zahl) {
|
||||
zahl++;
|
||||
}
|
||||
```
|
||||
---
|
||||
|
||||
```java
|
||||
public class TestFrame{
|
||||
int zahl;
|
||||
|
||||
public void m(){
|
||||
zahl = 3;
|
||||
}
|
||||
public void m2(){
|
||||
System.out.printf(zahl);
|
||||
}}
|
||||
```
|
||||
|
||||
---
|
||||
```java
|
||||
public class TestFrame {
|
||||
public int num;
|
||||
|
||||
public void m(int zahl){
|
||||
System.out.printf("1. %d %n", num);
|
||||
num++;
|
||||
int num = 4;
|
||||
System.out.printf("2. %d %n", num);
|
||||
num++;
|
||||
System.out.printf("3. %d %n", num);
|
||||
}
|
||||
public void m2(){
|
||||
num = 3;
|
||||
System.out.printf("4. %d %n", num);
|
||||
m(3);
|
||||
System.out.printf("5. %d %n", num);
|
||||
}}
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue