Enter your E-mail Address below for Free E-mail Alerts right Into your Inbox: -

Sunday

How does java store objects in memory

How does java store objects in memory

In java memory to all objects are dynamically allocated. When we declare a new object of some Class Type it just creates a reference to object. To allocate memory in heap "new" operator is Used.

Class Test{

     void addDetails()
{
System.out.println("abdjdbcbd");
}

public static void main(String a[])
{
Test t;
t.addDetails();  //runtime error not intialized
}

}

Class Test{

     void addDetails()
{
System.out.println("abdjdbcbd");
}

public static void main(String a[])
{
Test t = new Test();
t.addDetails();
}

}

No comments:

Post a Comment