Discussion:
i am new to java .
(too old to reply)
ashwin late
2020-09-02 05:36:58 UTC
Permalink
Area.java:12: error: '(' expected
public void get Area(){
^
Area.java:13: error: ')' expected
system.out.println("Area ="+set Dim());
^
Area.java:13: error: -> expected
system.out.println("Area ="+set Dim());
^
Area.java:13: error: not a statement
system.out.println("Area ="+set Dim());
^
Area.java:18: error: ';' expected
x.get Area();
^
5 errors
Eric Sosman
2020-09-02 12:09:36 UTC
Permalink
On 9/2/2020 1:36 AM, ashwin late wrote:

Because you've posted the error messages but not the source code
that provoked them, it's a little bit hard to see what you're trying
to do. But from the fragments of source shown in the messages I can
attempt a few guesses ...
Post by ashwin late
Area.java:12: error: '(' expected
public void get Area(){
^
If this is an attempt to define a method named "get Area", the
first problem is that names in Java cannot contain spaces: Spaces
*separate* things, but cannot be part of them. Try squeezing out
or replacing the space, arriving at "getArea" or "get_Area" or
something of that nature ("getArea" is probably more idiomatic).

The second problem is that a method name like "getArea" or
"getPerimeter" or "getSomething" usually indicates that the method
will return some information about its object. But yours is a
"void" method, meaning it cannot return any value at all! That's
not an error all by itself -- there's no RULE that says a method's
name must describe its function -- but it's certainly an oddity.
Ordinarily you would define the method to return a value of the
appropriate type; for example, if the "area" of your object is a
value of type "double" you might write

public double getArea() { ... }
Post by ashwin late
Area.java:13: error: ')' expected
system.out.println("Area ="+set Dim());
Again, the embedded space character is a no-no. Also, a method
with a name like "setSomething" is usually expected to set a new
value for some feature of its object, and that new value would
usually be supplied as an argument:

setDim(newDimensionValue)

Sorry I can't give a more complete diagnosis, but I can only see
a few tiny scattered bits of your Java code.
--
***@comcast-dot-net.invalid
When a witch hunt finds witches, pardon them.
One hundred forty days to go.
Loading...