我收到以下错误在我的Java程序:
Java变量未初始化错误...错误:变量越南和R未初始化的位置类子
不过nan
和r
已经初始化,但我仍然得到同样的错误。
public class cla {
int rn;
String name;
void get(String a, int x) {
name = a;
rn = x;
}
void display() {
System.out.println("student name: " + name + "roll no.:" + rn);
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class child {
public static void main(String args[]) throws IOException {
String nam;
int r;
BufferedReader bReader = new BufferedReader(new InputStreamReader(
System.in));
try {
System.out.println("enter name and roll no.");
nam = bReader.readLine();
r = Integer.parseInt(bReader.readLine());
} catch (Exception e) {
}
cla c = new cla();
c.get(nam, r);
c.display();
}