OnJava8-Examples/operators/PassObject.java
2015-04-29 13:56:17 -07:00

24 lines
438 B
Java

//: operators/PassObject.java
// Passing objects to methods might not be
// what you're used to.
import static net.mindview.util.Print.*;
class Letter {
char c;
}
public class PassObject {
static void f(Letter y) {
y.c = 'z';
}
public static void main(String[] args) {
Letter x = new Letter();
x.c = 'a';
print("1: x.c: " + x.c);
f(x);
print("2: x.c: " + x.c);
}
} /* Output:
1: x.c: a
2: x.c: z
*///:~