Java Basics: create class object
- by user1767853
In C++:
class Rectangle {
int x, y;
public:
void set_values (int,int);
int area () {return (x*y);}
};
int main () {
Rectangle rect;
rect.set_values (3,4);
}
In Java:
class Rectangle {
int x, y;
void set_values (int x,int y);
int area () {return (x*y);}
}
public static void main(String[] args) {
Rectangle rect=new Rectangle(3,4);
}
In C++ compiler will create rect object & reserve memory 4 bytes. I want to know How Java is creating object?