class Person{
private String name;
public Person(){
}
public Person(String name){
this.name=name;
}
public static void main(String[] arg)
{
Person per= new Person("Andy");
}
}
per is a local variable, where will it be stored, on the heap or the stack?
On the heap. Any time you use
newto create an object, it is allocated on the heap.