2017-09-10 1 views
-3

In diesem Code habe ich den Fehler (von Eclipse) „String kann nicht in eine Art gelöst werden“:Java Fehler: String kann nicht in eine Art gelöst werden (S ist in Großbuchstaben)

package tilegame.display; 

    import javax.swing.JFrame; 

    public class Display { 
     private JFrame frame; 
     private String title; 
     private int width, height; 
     public Display() { 
      public Display(String title, int width, int height){ 
       this.title = title; 
       this.width = width; 
       this.height = height; 
       createDisplay(); 
      } 
     } 
     public void createDisplay() { 
      frame = new JFrame(title); 
      frame.setSize(width, height); 
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
      } 
     } 

ich gesucht, aber " String "ist upercase und ich habe die Java Library von Eclipse.

+4

Warum haben Sie einen Konstruktor in einem anderen? – user2357112

Antwort

0

Verschachteln Sie die Konstruktoren nicht. Versuchen Sie dies:

package tilegame.display; 

import javax.swing.JFrame; 

public class Display { 
    private JFrame frame; 
    private String title; 
    private int width, height; 
    public Display() { 

    } 
    public Display(String title, int width, int height){ 
     this.title = title; 
     this.width = width; 
     this.height = height; 
     createDisplay(); 
    } 
    public void createDisplay() { 
     frame = new JFrame(title); 
     frame.setSize(width, height); 
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    } 
} 
Verwandte Themen