Results 1 to 3 of 3

Thread: ';' expected

  1. #1
    lala is offline Member
    Join Date
    Oct 2010
    Posts
    80
    Rep Power
    0

    Default ';' expected

    Can anyone see why the compiler generated this msg:
    ForAct.java:7: ';' expected
    public static void main(String[] args)
    ^

    Java 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

  2. #2
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    You do not have a { after your main() declaration.

    Additionally, methods cannot go inside other methods. It should be something like this instead:
    Java 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);		*/	
    	}
    }

  3. #3
    lala is offline Member
    Join Date
    Oct 2010
    Posts
    80
    Rep Power
    0

Similar Threads

  1. Line:38: ';' expected
    By lala in forum New To Java
    Replies: 3
    Last Post: 11-22-2010, 03:35 AM
  2. .class expected
    By dre in forum New To Java
    Replies: 6
    Last Post: 06-27-2009, 07:01 PM
  3. identifier expected
    By tlouvierre in forum New To Java
    Replies: 4
    Last Post: 05-28-2009, 01:11 AM
  4. The values are NOT as expected...
    By Abder-Rahman in forum New To Java
    Replies: 4
    Last Post: 05-09-2009, 01:01 AM
  5. MSG ERROR: : expected
    By Marty in forum New To Java
    Replies: 1
    Last Post: 05-31-2007, 03:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •