I have this constructor with a function however when i compile my main method i non-static method area cannot be referenced from a static context. I know its a simple fix i just
You have 2 options.
Which one to chose is purely a design decision.
You would need to call the method on an instance of the class.
This code:
Rect rect = new Rect (x, y, height, width);
double area = Rect.area();
Should be:
Rect rect = new Rect (x, y, height, width);
double area = rect.area();
^ check here
you use rect variable, not Rect class
Java is Case Sensitive