Posts

Showing posts with the label use of new operator in java

Job of new operator in java

What does new operator do? new operator in java is used for creating the object of the class. new operator instantiates the class and allocates memory to the object . As an object is instantiated all non-static member of the class are activated and ready to be used. It is the well known working of new operator, I want to tell you what happens in the memory when an object is created in the memory i.e. job of new operator or responsibilities of new operator in java programming. We will discuss step by step jobs of new operator. First i want to tell you how we create an object? class_name <reference variable> = new class_name(); Here,  <reference variable> is the variable of specified class and it stores the hashcode(address of object where it has been created) returned by the new operator. hashcode is in the form of hexadecimal code. Now we will discuss job of new operator. If .class file is not loaded  then to load the .class file from hard disk...