forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRiddle.java
More file actions
23 lines (18 loc) · 468 Bytes
/
Riddle.java
File metadata and controls
23 lines (18 loc) · 468 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.awt.Point;
/**
* Exercise on passing objects as parameters.
*/
public class Riddle {
public static int riddle(int x, Point p) {
x = x + 7;
return x + p.x + p.y;
}
public static void main(String[] args) {
int x = 5;
Point blank = new Point(1, 2);
System.out.println(riddle(x, blank));
System.out.println(x);
System.out.println(blank.x);
System.out.println(blank.y);
}
}