What is an object reference in java
1. The concept of reference
If a variable The type is a class type, not a basic type, then the variable is also called a reference. In fact, GC mainly depends on whether the object has a reference pointing to the object. According to the strong and weak relationship of this reference, starting from JDK1.2 version, object references are divided into four levels, so that the program can more flexibly control the life cycle of the object. These four levels, from high to low, are: strong reference, soft reference, weak reference and virtual reference.
2. Object reference
Reference and pointer
new Hero(); represents the creation of a Hero object, but it only creates an object and has no way to access it. In order to access this object, a reference will be used to represent the object Hero h = new Hero();
hThis variable is of type Hero, also called a reference, = It means that the reference h represents the object created on the right "representative". In object-oriented, it is also called "pointing".
So, the reference to an object in Java is a class type variable pointing to the created object.
php Chinese website, a large number of free Java introductory tutorials, welcome to learn online!
The above is the detailed content of What is an object reference in java. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools