Wednesday, 2 December 2015

Java Tutorial : Java how to unreference an Object


Click here to watch in Youtube :
https://www.youtube.com/watch?v=HZpOJzSfws0&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java how to unreference an Object
Java Tutorial : Java how to unreference an Object
Java Tutorial : Java how to unreference an Object
Java Tutorial : Java how to unreference an Object

Student.java
public class Student
{

    String name;
    int age;

    public Student(String name, int age)
    {
        this.name = name;
        this.age = age;
    }

}
StudentTest.java
public class StudentTest
{

    public static void main(String[] args)
    {
        Student johnReferenceVariable = new Student("John", 25);
        johnReferenceVariable = null; // now the object referred by
                                        // johnReferenceVariable is available
                                        // for garbage collection

        Student ref1 = new Student("Juli", 25);
        Student ref2 = new Student("Dave", 29);
        ref1 = ref2; // now the first object referred by ref1 is available for
                        // garbage collection.

        new Student("Peter", 28);
        
    }

}
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/UnreferenceObjectDemoApp.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/UnreferenceObjectDemoApp/UnreferenceObjectDemo

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/68054fa19b88e552162495a83ba964283753af15/BasicJava/UnreferenceObjectDemoApp/UnreferenceObjectDemo/?at=master

See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment