2
私はAndroidに慣れていて、Javaには新しくなっていますが、プログラミングには新しくない(Eclipseを使用しています)。私は方法の中でこのようなサンプルコードを実行しようとしています:InputStreamを宣言する
private void dummy() {
try {
URL url = new URL(quakeFeed);
URLConnection connection;
connection = url.openConnection();
HttpURLConnection httpconnection = (HttpURLConnection)connection;
int responseCode = httpconnection.getResponseCode();
if(responseCode == HttpURLConnection.HTTP_OK)
InputStream inp = new BufferedInputStream(httpconnection.getInputStream());
}
...
}
他のすべての構文と変数が定義されているものとします。理由もjava.io.InputStream;
私は法の外InputStream
を宣言した場合、エラーが消灯をインポートした後に奇妙である
InputStream` cannot be resolved to a variable.
、すなわち
InputStream inp;
private void dummy() {
try {
URL url = new URL(quakeFeed);
URLConnection connection;
connection = url.openConnection();
HttpURLConnection httpconnection = (HttpURLConnection)connection;
int responseCode = httpconnection.getResponseCode();
if(responseCode == HttpURLConnection.HTTP_OK)
// Changed
inp = new BufferedInputStream(httpconnection.getInputStream());
}
...
}
私は好奇心:私は次のエラーを取得しますローカル宣言InputStream
を解決できませんでしたが、グローバル宣言は解決されました。
[OK]をおかげで私はこのことを認識波平。 –