[Java] I was addicted to the roll method

less than 1 minute read

In the calendar class roll method, specify which part of the date is changed in the first argument and the change value in the second argument.

If there is a variable with 4/1 set and you execute it by specifying “day” as the first argument and “-1” as the second argument of the roll method, what will the value of the variable be?

It’s likely to be 3/31 as the day goes back one day, but it’s actually 4/30.

It seems to be 3/31 with the add method.