|
@@ -0,0 +1,60 @@
|
|
|
+package com.sf.day06;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 这是一个学生类
|
|
|
+ */
|
|
|
+public class Student {
|
|
|
+ String stuNo;
|
|
|
+ String name;
|
|
|
+ int age;
|
|
|
+ double weight;
|
|
|
+ double height;
|
|
|
+
|
|
|
+ public void study(){
|
|
|
+ System.out.println("学生学习");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void sleep(String name){
|
|
|
+ System.out.println(name+" 不好好学习 正在睡觉");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String toString() {
|
|
|
+ return "Student{" +
|
|
|
+ "stuNo='" + stuNo + '\'' +
|
|
|
+ ", name='" + name + '\'' +
|
|
|
+ ", age=" + age +
|
|
|
+ ", weight=" + weight +
|
|
|
+ ", height=" + height +
|
|
|
+ '}';
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 返回当前类对象的信息
|
|
|
+ */
|
|
|
+// @Override
|
|
|
+// public String toString() {
|
|
|
+// return "Student { stuNo = "+stuNo
|
|
|
+// +", name = "
|
|
|
+// +name
|
|
|
+// +",age +"
|
|
|
+// +age+",weight = "
|
|
|
+// +weight+",height"
|
|
|
+// +height+"}";
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ Student student = new Student();
|
|
|
+ student.stuNo = "1001";
|
|
|
+ student.name = "xss";
|
|
|
+ student.age = 18;
|
|
|
+ student.height = 138.6;
|
|
|
+ student.weight = 100.0;
|
|
|
+ student.study();
|
|
|
+ student.sleep(student.name);
|
|
|
+ String str = student.toString();
|
|
|
+ System.out.println(str);
|
|
|
+ }
|
|
|
+}
|