java error: constructor call must be the first statement in a constructor

后端 未结 4 1849
忘了有多久
忘了有多久 2021-01-22 17:37

The following code returns me an error saying:
\"constructor call must be the first statment in a constructor.\"

I dont get it. The constructor in my c

4条回答
  •  庸人自扰
    2021-01-22 18:27

    Ideally your code should fail saying Invalid Method declartion because public labelFrame()

    • is neither a constructor (because constructor has the same name as the class name).
    • is neither proper method declaration.

    Whatever change your code like this:

    public class labelsAndIcons extends JFrame
    {
      public labelsAndIcons ()
      {
         super( "Testing JLabel" );
      }
    }
    

提交回复
热议问题