で変数の内容を取得することができません:私はこれらの変数の内容を取得する問題が持っているJavaの
try{
InputStream flux = new FileInputStream("file.txt");
InputStreamReader read = new InputStreamReader(flux);
BufferedReader buff = new BufferedReader(read);
String ligne, ligne1;
while ((ligne = buff.readLine())!=null)
{
if(ligne.startsWith("k"))
{
first = Integer.parseInt(ligne.substring(6, 9));
second = Integer.parseInt(ligne.substring(10, 13));
}
}
while ((ligne1 = buff.readLine())!=null)
{
if(ligne1.startsWith("e"))
{
int ind1 = ligne1.lastIndexOf(" ");
n1 = Integer.parseInt(ligne1.substring(2, ind1));
n2 = Integer.parseInt(ligne1.substring(ind1+1));
}
}
...
// Displaying of their content
System.out.println(first); // ok
System.out.println(second); // ok
System.out.println(n1); // doesn't work content 0
System.out.println(n2); // doesn't work content 0
私は彼らのコンテンツを表示したくない:怒鳴るコードでは、N1らN2をしばらく。 ありがとうございます!
「System.out.println(n1);」は「ok」ですが、「System.out.println(n1);」は「コンテンツ0は動作しません」というのはなぜですか? –
エラー、それは秒でした。私はすでにそれを修正しました。 – hitech
入力とは何ですか?あなたは何を期待していますか?何を手に入れますか? n1、n2、firstとsecondはどこに宣言されていますか? – Heri