-
';' expected
Can anyone see why the compiler generated this msg:
ForAct.java:7: ';' expected
public static void main(String[] args)
^
Code:
import java.util.*;
import javax.swing.JOptionPane;
public class ForAct
{
public static void main(String[] args)
public static double larger (double x, double y, double z)
{
x = 4.0;
y = 1.0;
z = 3.0;
double max;
if (x >= y)
max = x;
else max = y;
return max;
/* System.out.println(x + y + max); */
}
}
Thanks
-
You do not have a { after your main() declaration.
Additionally, methods cannot go inside other methods. It should be something like this instead:
Code:
import java.util.*;
import javax.swing.JOptionPane;
public class ForAct
{
public static void main(String[] args) {
}
public static double larger (double x, double y, double z)
{
x = 4.0;
y = 1.0;
z = 3.0;
double max;
if (x >= y)
max = x;
else max = y;
return max;
/* System.out.println(x + y + max); */
}
}
-
(SOLVED) ';' expected