Java Method Parameters pass an object to a method

Question

What is the output of the following code?

class City {//from  w  w  w.j a  v  a 2 s.co m
  int population;
}

public class Main {

  public static void main(String args[]) {
    City city = new City();
    city.population = 2232;
    birth(city);
    System.out.println(city.population);
  }

  static void birth(City aCity) {
    aCity.population++;
  }
}


2233



PreviousNext

Related