Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #4334

Re: i am new to java .

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.help
Subject Re: i am new to java .
Date 2020-09-02 08:09 -0400
Organization A noiseless patient Spider
Message-ID <rio222$le1$1@dont-email.me> (permalink)
References <0a492d77-0dfc-4efc-83b2-27698a0856f7n@googlegroups.com>

Show all headers | View raw


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.

Back to comp.lang.java.help | Previous | NextPrevious in thread | Find similar


Thread

i am new to java . ashwin late <ashwinlate6008@gmail.com> - 2020-09-01 22:36 -0700
  Re: i am new to java . Eric Sosman <esosman@comcast-dot-net.invalid> - 2020-09-02 08:09 -0400

csiph-web