Netbeans Java非法公共静态无效编译



public static void DemoMethod()中抛出错误。为什么?

 package demoblock;
  /**
  *
  * @author coleen
  */
  public class DemoBlock {
  /**
  * @param args the command line arguments
  */
  public static void main(String[] args) {
    System.out.println("Demontrating block scope");
    int x = 1111;
    System.out.print("in first block x is" + x);        
    {
        int y = 2222;
        System.out.println(" In second block x is " + x);
        System.out.println(" In seond block y is " + y); 
    }
    {
        int y = 3333;
        System.out.println(" In third block x is " + x);
        System.out.println(" In third block y is " + y);
        DemoMethod();
        System.out.println(" After method x is " + x);
        System.out.println(" After method block y is " + y);            
        System.out.println(" At the end x is " + x); 
        public static void DemoMethod()
        {
         int x = 8888;
         int y = 9999;
                 System.out.println(" In demoMethod x is " + x);
                 System.out.println(" In DemoMethod block y is " + y);                    
        }    
    }
/** * * @author coleen */
public class DemoBlock
{
    /**
     * @param args
     *            the command line arguments
     */
    public static void main( String[] args )
    {
        System.out.println( "Demontrating block scope" );
        int x = 1111;
        System.out.print( "in first block x is" + x );
        {
            int y = 2222;
            System.out.println( " In second block x is " + x );
            System.out.println( " In seond block y is " + y );
        }
        {
            int y = 3333;
            System.out.println( " In third block x is " + x );
            System.out.println( " In third block y is " + y );
            DemoMethod();
            System.out.println( " After method x is " + x );
            System.out.println( " After method block y is " + y );
            System.out.println( " At the end x is " + x );
        }
    }
    public static void DemoMethod()
    {
        int x = 8888;
        int y = 9999;
        System.out.println( " In demoMethod x is " + x );
        System.out.println( " In DemoMethod block y is " + y );
    }
}

相关内容

  • 没有找到相关文章