search
Login

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

0 votes
88 views
asked Geek 15.3k points 16 41 63

1 Answer

0 votes
class Point {
  public int x;

  public int y;
}

public class MainClass {
  public static void increment(int x) {
    x++;
  }

  public static void reset(Point point) {
    point.x = 0;
    point.y = 0;
  }

  public static void main(String[] args) {
    int a = 9;
    increment(a);
    System.out.println(a); // prints 9
    Point p = new Point();
    p.x = 400;
    p.y = 600;
    reset(p);
    System.out.println(p.x); // prints 0
  }
}
output
9
0
answered Sr Member 4.8k points 10 25 31

Related questions

0 votes
1 answer 89 views
89 views
asked augustaina Sr Member 4.8k points 10 25 31
0 votes
1 answer 175 views
0 votes
1 answer 17 views
17 views
asked smith Geek 15.3k points 16 41 63
0 votes
1 answer 88 views
0 votes
1 answer 92 views
92 views
asked augustaina Sr Member 4.8k points 10 25 31
...