Java面向对象练习学生信息输出
package com.text_1;

public class student {
	//编写Java应用程序。首先,定义描述学生的类——Student,包括学号(int)、
	//姓名(String)、年龄(int)等属性;二个方法:Student(int stuNo,String name,int age)
	//用于对对象的初始化,outPut()用于输出学生信息。其次,再定义一个主类——
	//TestClass,在主类的main方法中创建多个Student类的对象,使用这些对象来测
	//试Student类的功能。
	         int stuNo,age;
	         String name;
	         student(int stuNo,String name,int age)
	         {
	        	 this.stuNo=stuNo;
	        	 this.name=name;
	        	 this.age=age;
	         }
	         void outPut()
	         {
	        	 System.out.println("学号:"+this.stuNo+"\n"+"姓名:"+this.name+"\n"+"年龄:"+this.age);
	         }
	        public static void main(String[] args)
	        {
	        	  
	        	student  stu=new student(28,"张三",12);
	        	
	        	stu.outPut();
	        	
	        	
	        	
	        }


}

 

相关文章:

  • 2022-01-02
  • 2021-10-04
  • 2021-11-01
  • 2021-10-04
  • 2022-12-23
  • 2021-12-31
  • 2022-01-27
  • 2022-01-31
猜你喜欢
  • 2021-10-04
  • 2022-12-23
  • 2021-10-04
  • 2021-10-04
  • 2021-12-15
  • 2021-11-01
相关资源
相似解决方案