我正在尝试构建一个与 Twitter 相关的简单应用程序。我已经阅读了很多关于它的教程,但是我在代码的早期步骤中遇到了错误。
Twitter twitter = new TwitterFactory().getInstance(txtUsername.getText(),arrayToString(txtPassword.getPassword()));
其中 txtUsername 是编辑文本,txtPassword 是密码字段。 arrayToString方法是这样的
private String arrayToString(char[] arr)
{
StringBuffer result = new StringBuffer();
for(int i=0;i<arr.length;i++)
{
result.append(arr[i]);
}
return result.toString();
}
这是错误
no suitable method found for getInstance(java.lang.String,java.lang.String)
method twitter4j.TwitterFactory.getInstance(twitter4j.auth.Authorization) is not applicable
(actual and formal argument lists differ in length)
method twitter4j.TwitterFactory.getInstance(twitter4j.auth.AccessToken) is not applicable
(actual and formal argument lists differ in length)
method twitter4j.TwitterFactory.getInstance() is not applicable
(实际参数列表和形式参数列表的长度不同)
非常感谢您,任何帮助都会非常有用..
最佳答案
您尝试使用的 getInstance
方法在 Twitter4J 中不存在。如果你看javadoc您将看到三个 getInstance
方法可用:
Twitter getInstance()
Twitter getInstance(AccessToken accessToken)
Twitter getInstance(Authorization auth)
这就是为什么你的编译器提示使用:
getInstance(String, String)
关于java - TwitterFactory().getInstance() 没有获取合适的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20195218/