• i am new to java .

    From ashwin late@21:1/5 to All on Tue Sep 1 22:36:58 2020
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eric Sosman@21:1/5 to value of type "double" you might on Wed Sep 2 08:09:36 2020
    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 ...

    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() { ... }

    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.


    --
    esosman@comcast-dot-net.invalid
    When a witch hunt finds witches, pardon them.
    One hundred forty days to go.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)