简体   繁体   中英

Why there still have error return type required?

I want to draw a line from value in function before. Therefore, I need a return function so, it more smoothly to draw a line in graphic function.

I confused, why there still error since I was put the return function. Please help me..

"Program.java:45: invalid method declaration; return type required"

   public static SLL(int SLL)

   public Program()
  {
     super("MyProgram"); //window name
     .....
     computeButton.addActionListener(this);
  }


   public void actionPerformed(ActionEvent ee)
  {
  }
   public static SLL(int SLL)
  {  ....

     HomePosition HP[][] = new HomePosition[2][6];
     HomePosition DP[][]= new HomePosition[2][6];
     HomePosition FB[][] =new HomePosition[2][6];
     ...
     FB[1][0].x= FB[2][0].x=40;
     FB[1][0].y=FB[2][0].y=40;

     HP[1][0].x = 40;       HP[1][0].y = 30;        
     HP[1][1].x = 26;       HP[1][1].y = 30;       


     DP[1][0].x = 30;           DP[1][0].y =40;    
     DP[1][1].x = 16;           DP[1][1].y = 40;   

     SLL.SLx[m][n]=HP[m][n].x;

     return SLL;
  }

   public void paint(Graphics g) {
     super.paint(g);      
     }


      BasicStroke stroke;
     Graphics2D g2 = (Graphics2D)g;

     stroke = new BasicStroke(4.0f); 
     g2.setStroke(stroke);
    .....
      for (m=1;m<=2;m++){
        for (n=0;n<=1;n++){
             g2.drawLine( SLL.SLx[m][n]*M,40*M,40*M,30*M);
        }
     }
  }

   public static void main(String[] arguments)
  {
     Program frame=new Program();
     final int WIDTH=910;
     final int LENGTH=725;
     frame.setSize(WIDTH,LENGTH);
     final int buttonWidth=30;
     final int buttonHeight=10;
     frame.setVisible(true);
  }
}

You are not stating your return type. It should be

public static int SSL(...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM