创建类,并输出相关信息比较简单,话不多说,干货奉上。
package out.alibaba; /** * Created by 86176 on 2021/7/22. */ public class Student { String stuname; int stuage; int stucalss; String stulike; public void sxs(){ System.out.println("姓名:"+stuname+"\n年龄:"+stuage+"\n班级:"+stucalss+"\n爱好:"+stulike); } public static void main(String[] args) { Student student=new Student(); student.stuname="老司机"; student.stuage=20; student.stucalss=2107; student.stulike="二次元小萌妹,腐眼看人基!"; student.sxs(); } }