`
jingle1267
  • 浏览: 12695 次
文章分类
社区版块
存档分类
最新评论

定义类并应用

 
阅读更多

//StudentTest.java

class Student{
String name;
String telphone;
Student(String a,String b){
name=a;telphone=b;
}
void showMessage(){
System.out.print(" "+name+":");
System.out.println(""+telphone+"/n");
}
}
class StudentTest{
public static void main(String[] args){
Student stuA=new Student("jingle","13525166785");
System.out.println("StudentA's information:");
stuA.showMessage();
Student stuB=new Student("MeiFei","13525135004");
System.out.println("StudentB's information:");
stuB.showMessage();
}
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics