这是我要实例化的类(class):
public class GoogleSheetsAPI {
String spreadsheetId;
Sheets service;
String credentialsFile;
public void GoogleSheetsAPI() {
}
public void GoogleSheetsAPI(String spreadsheetId, String credentialsFile) throws Exception {
this.spreadsheetId = spreadsheetId;
this.credentialsFile = credentialsFile;
service = getSheetsService();
}
}
这就是我创建类
GoogleSheetsAPI
的对象的方式GoogleSheetsAPI googleSheetsAPI = new GoogleSheetsAPI(spreadsheetId, credentiialsFile);
最佳答案
构造函数不得具有void
,应为:
public GoogleSheetsAPI(String spreadsheetId, String credentialsFile) throws Exception {
this.spreadsheetId = spreadsheetId;
this.credentialsFile = credentialsFile;
service = getSheetsService();
}