learning the programming language also has a few years, but for the programming language syntax in the computer memory of some of the call relationship has been unclear, until recently, in learning Java when you get to know something. So this concludes.
First look at a section of code:
Class Point{private double x;private double y; Point (double x1,double y1) {x=x1;y=y1;} Public double GetX () {return x;} Public double GetY () {return y;} public void SetX (double i) {x=i;} public void Sety (double j) {y=j;}} Class Circle{private point o;private double radius; Circle (Point p,double R) {o=p;radius=r;} Circle (Double R) {o=new point (0.0,0.0); radius=r;} Boolean contains (point P) {Double x = P.getx ()-O.getx ();d ouble y = p.gety ()-o.gety (); if (x*x+y*y> radius + radius) re Turn false;else return true;} public void SetO (double x, double y) {o.setx (x); o.sety (y);} Public Point Geto () {return o;} Public double Getradius () {return radius;} public void Setradius (double R) {radius=r;} Public double area () {return 3.14 * radius * RADIUS;}} public class Testcircle{public static void Main (String arg[]) {Circle C1=new Circle (New Point (1.0,2.0), 2.0); Circle C2 =new Circle (5.0);//Slightly ***********************
}}
when the program executes to the Circle C1=new Circle (New Point (1.0,2.0), 2.0);in this sentence, the program is parsed from inside out.
The actual memory usage is as follows:
, the large box on the left represents the stack in memory, and the right side represents the heap in memory.
when the program New an object, a constructor of the object is always called first to implement the parameter assignment to the object.
In the diagram, the large box on the left represents the stack in memory, and the right side represents the heap in memory, as is the following illustration.
Memory Analysis in the program