我有一個愚蠢的問題給你們,因爲我得到這個代碼的錯誤。Java類和返回
這是我的第一個Stackoverflow帖子,很抱歉,如果我犯了什麼錯誤。
我想要說這返回一個布爾值(true或false):
VerifyClassUnlocked.verify(account.email,account.password,"PRIEST");
在另一大類。
package realmclient;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
public class VerifyClassUnlocked {
public static boolean verify(String EMAIL, String PASSWORD, String CLASS) {
URL url;
InputStream is = null;
BufferedReader br;
String line;
try {
url = new URL("https://realmofthemadgod.appspot.com/char/list?guid="+EMAIL+"&password="+PASSWORD);
is = url.openStream(); // throws an IOException
br = new BufferedReader(new InputStreamReader(is));
while ((line = br.readLine()) != null) {
System.out.println(line);
if (line.contains("<ClassAvailability id=\""+CLASS+"\">unrestricted</ClassAvailability>")){
return true;
}else{
return false;
}
}
} catch (MalformedURLException mue) {
mue.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (is != null) is.close();
} catch (IOException ioe) {
// nothing to see here
}
}
}
}
你會得到什麼錯誤?這應該是你發佈的第一件東西,你首先要搜索的東西。 –
請提及問題併發布**特定問題**。 – Christian
感謝您快速回答的人。 我的問題是這樣的: public static boolean verify(String EMAIL,String PASSWORD,String CLASS){ 不正確。 它說「它必須返回一種布爾類型」。 – Alde