Re: Help -- New to Java



Bjorn Abelli wrote:
public static int double(int[] p) {

You'll need a method name that isn't a keyword.


// Here you put in the logic to calculate the average

}

The main difference from C in this aspect is that you need to use the keyword "static". Otherwise it becomes an "instance member" instead of a "class member".

No, you don't. This could just as well be an instance method.

--
Lew
.



Relevant Pages

  • Re: Help -- New to Java
    ... Bjorn Abelli wrote: keyword "static". ... Otherwise it becomes an "instance member" instead of a "class member". ... For non-instantiable utility classes I use only static methods and no instance anythings. ...
    (comp.lang.java.help)
  • Re: Non static method error explanation?
    ... programmer use...use/add the keyword "static" in the calledRoutine line ... then it must be an instance member. ... If the method accesses state that might be used by more than one ...
    (comp.lang.java.help)