G
Guest
Gast
Hallo ich habe diese Programmteile kann mir mal jemand erklären wie ich die Parameterübergabe erkläre??
beim Aufruf der Funktionen f1(i),f2(k)
Die Ausgabe is ja 1,2
Danke
beim Aufruf der Funktionen f1(i),f2(k)
Code:
00 class Foobar{
01 public static void f1(int j){
02 j = 3;
03 } //f1
04 public static void f2(MyInt l){
05 MyInt newInt = new MyInt(4);
06 l = newInt;
07 } //f2
08 public static void main(String[] args){
09 int i = 1;
10 MyInt k = new MyInt(2);
11 f1(i);
12 System.out.println(i);
13 f2(k);
14 System.out.println(k.toString());
15 } //main
16 } //Foobar
Code:
class MyInt{
01 private int cont = 0;
02
03 public MyInt(){
04 cont = 0;
05 } //Konstruktor parameterlos
06
07 public MyInt(int x){
08 cont = x;
09 } //Konstruktor
10
11 public String toString(){
12 return "" + cont;
13 } //toString
14 } //MyInt
Die Ausgabe is ja 1,2
Danke