chesskidd
10-07-2003, 07:38 AM
Hello guys, I'm learning Java at school this semester.
I have some background in C++ (intro level) before.
I'm writing a program and I want to pass a function and its values into main ( not sure if i called it correctly, what's the difference between a function and a method?, confused :confused: ). okay, i wrote this function inside the
public static void main(String args[])
{ ........
........ // ... means these are some codes
double a, b;
sorted (a, b);
.........
// then the function that i wrote:
public sorted(double a, double b)
{
double temp;
if( a < b)
{ temp=b;
b=a;
a=temp;
}
} // sort function
) // main method
afterall, i tried to compile the program, it gave me an error as below:
lab1.java:62: illegal start of expression
public sorted(double a, double b)
^
why??
something wrong with the declaration of the "function" ?
or the wrong function call in the main ? :(
any java guru? help is really appericated.
I have some background in C++ (intro level) before.
I'm writing a program and I want to pass a function and its values into main ( not sure if i called it correctly, what's the difference between a function and a method?, confused :confused: ). okay, i wrote this function inside the
public static void main(String args[])
{ ........
........ // ... means these are some codes
double a, b;
sorted (a, b);
.........
// then the function that i wrote:
public sorted(double a, double b)
{
double temp;
if( a < b)
{ temp=b;
b=a;
a=temp;
}
} // sort function
) // main method
afterall, i tried to compile the program, it gave me an error as below:
lab1.java:62: illegal start of expression
public sorted(double a, double b)
^
why??
something wrong with the declaration of the "function" ?
or the wrong function call in the main ? :(
any java guru? help is really appericated.