> Isn't correct to make a program like this (to make the method outside
> the main program, but in the same file):
Assuming that's a question, yes, it is correct. It worked for you, didn't it?
> public class Program
> {
> static double f(double x)
Do not embed TAB characters in Usenet source listings. It makes life hard on
those using newsreaders (everyone).
A reasonable indentation is two to four spaces per level.
> {
> return 3*x*x*x + 2*x*x + 0.2;
[quoted text clipped - 5 lines]
> }
> }
A small point - instead of thinking of your source as a "file", think of it as
a "class". The fact that the class is specified in a file is secondary to its
purpose.
Note that the method 'f()' has package-private (a.k.a., "default") access as
declared. Package-private is a very useful access level, maybe not what you
need right here this time but useful. It does no harm here.
Likewise note that the arguments to f() as provided are ints, implicitly
widened to double by the mechanics of method invocation.

Signature
Lew
(-Peter-) - 12 Nov 2007 18:46 GMT
> > Isn't correct to make a program like this (to make the method outside
> > the main program, but in the same file):
[quoted text clipped - 33 lines]
> --
> Lew
thank you for the comments, and yes - it did work :-)
/Peter