What is the output of the following code?
public class Main{ public static void main(String[] argv){ LocalDate date = LocalDate.of(2016, Month.APRIL, 30); date.plusDays(2); date.plusYears(3); System.out.println(date.getYear() + " " + date.getMonth() + " " + date.getDayOfMonth()); } }
B.
Since dates are immutable, and the result is unchanged.
//w w w. java 2 s. c o m public class Main{ public static void main(String[] argv){ LocalDate date = LocalDate.of(2016, Month.APRIL, 30); date.plusDays(2); date.plusYears(3); System.out.println(date.getYear() + " " + date.getMonth() + " " + date.getDayOfMonth()); } }
The code above generates the following result.