I've just started learning Java. I'm reading this book: Intro to Java Programming, Comprehensive Version (10th_Edition). In chapter 9, there's a simple program:
import java.util.Date;
public class Test {
public static void main(String[] args) {
Date date = null;
m1(date);
System.out.println(date);
}
public static void m1(Date date) {
date = new Date();
}
}
As I understand the method creates a new object and assigns It to the reference variable that was passed to It. Why does It still print null after calling the method? Thanks for your answers.