// JavaProject CallDemo

// CallDemo.java
import javax.swing.*;
class Int {
int n;
Int(int n) {
setValue(n);
}
void setValue(int v) {
n = v;
}
int getValue() {
return n;
}
}
class Calls {
void setValue(int n, int v) {
//
Überladen von Methoden
n = v;
System.out.print(n + ", ");
}
void setValue(Integer n, int v) {
n = v;
System.out.print(n + ", ");
}
void setValue(Int n, int v) {
n.setValue(v);
System.out.print(n.getValue() + ", ");
}
void setValue(String str, String v) {
str = new String(v);
System.out.print(str + ", ");
}
void setValue(JLabel lbl, String v) {
lbl.setText(v);
System.out.println(lbl.getText());
System.out.println();
}
void output(int a, Integer b, Int c, String d, JLabel e) {
String s = a + ", ";
s = s.concat(b + ", ");
s = s.concat(c.getValue() + ", ");
s = s.concat(d + ", ");
s = s.concat(e.getText());
System.out.println(s);
System.out.println();
}
Calls() {
int i = 3;
Integer j = Integer.decode("3");
Int k = new Int(3);
String l = "3";
JLabel m = new JLabel("3");
output(i, j, k, l, m);
setValue(i, 5); //
call by value
setValue(j, 5); // call by value
setValue(k, 5); // call by reference
setValue(l, "5"); // call by value
setValue(m, "5"); // call by reference
output(i, j, k, l, m);
}
}
class CallDemo {
public static void main(String[] args) {
new Calls();
}
}
Download CallDemo