分别建立2个类class works 和 Personimport java.io.*
;
public class works {
public static void main(String[] args)
{
Person ZhangSan=
new Person();
InputStreamReader stdin =
new InputStreamReader(System.in);
BufferedReader bufin =
new BufferedReader(stdin);
try{
System.out.println("please Input his Name"
);
ZhangSan.Name =
bufin.readLine();
System.out.println("please Input his Age"
);
ZhangSan.Age =
bufin.readLine();
ZhangSan.talk();
} catch(Exception e)
{
System.err.println("error"
);
}
}
}
public class Person {
String Name;
String Age;
void talk()
{
System.out.println("I'm "+Name+", I'm "+Age+",year old");
}
}
转载于:https://www.cnblogs.com/zhaocundang/p/4865140.html
相关资源:JAVA上百实例源码以及开源项目