Hey guys. I'm having trouble on a beginners java assignment, and not touching Java in two years has not helped at all.
My question is relatively easy and is for beginners;
I am to create a main.java class which I have to define a circle object and instantiate it, then using instance methods to call upon the results from Circle.java class to Main.java class.
How do I call upon the Circle.class object? I'm supposed to ask the user to input data from the main.java class, where the circle.java class uses the input data to calculate results, which then I have to use instance methods to call upon the results.
I thought to call upon an object it would be:
Circle c = new Circle();
However the error I get is:
constructor circle in class Circle cannot be applied to given types;
found: no arguments
reason: actual and formal argument lists differ in length
Is it wrong because instead of passing no arguments, I was supposed to put (double radius)?
Creating Objects (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
I am using this website to try and figure it out myself, but I get confused because:
my first step is to define the object, which would be the Circle c = new Circle(); yes? in the website they give an example to: Point originOne = new Point(23, 94);
I am then to instantiate it, which creates an instance of the object. However, they give the same example for instantiating which is: Point originOne = new Point(23, 94);
So I'm a bit confused as to what the difference is between defining an object and instantiating it.
I think I got the defining and instantiating the object correctly, I changed the code to:
radius = getRadius();
info = new Circle (radius);
which covers the defining and intiantiazing, but how do I output the results as an instance method?