繁体   English   中英

错误:此类应提供默认构造函数 (.....) [可实例化]

[英]Error : This class should provide a default constructor (.....) [Instantiatable]

我收到以下错误:

错误:此类应提供默认构造函数(无参数的公共构造函数)(com.mrad4tech.development.sportss.TwitterAPI)

[Instantiatable]

package com.mrad4tech.development.sportss;

public class TwitterAPI {

    private String twitterApiKey;
    private String twitterAPISecret;
    final static String TWITTER_TOKEN_URL = "https://api.twitter.com/oauth2/token";
    final static String TWITTER_STREAM_URL = "https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=";

    public TwitterAPI(String twitterAPIKey, String twitterApiSecret){
        this.twitterApiKey = twitterAPIKey;
        this.twitterAPISecret = twitterApiSecret;
    }

    ...
}        

请帮帮我

您需要一个无参数构造函数:

public TwitterAPI(){
}

错误说明了一切,您应该提供一个默认构造函数。
将此添加到您的课程中:

public TwitterAPI() {

}

将默认构造函数添加到您的类TwitterAPI

//Default constructor takes no arguments
public TwitterAPI() { 
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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