Re: Help -- New to Java




"Lew" <lew@xxxxxxxxxxxxxxxx> skrev i meddelandet
news:oKadndziTJs7OjXbnZ2dnUVZ_sLinZ2d@xxxxxxxxxxxxxx
Bjorn Abelli wrote:
public static int double(int[] p) {

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

I changed it just before I sent it, from

public static int mean(int[] p) {

....as I intended to change the return type, but changed at the wrong
place... ;-)

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.

Yes, he does, as his assignment explicitly says so... ;-)


/// Bjorn A


.



Relevant Pages

  • Re: current type in static methods
    ... >> because using GetTypeor class has a different meaning, ... >> instance method is useful too ... the first option alters the meaning of the "this" ... keyword which is not good. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: random number generator help
    ... You are calling an instance method from a static method. ... It will work if you add the keyword "static" to the instance method: ... private static int RandomNumber ... Random random = new Random; ...
    (microsoft.public.dotnet.languages.csharp)