class student{
public String name;
public int age;
public int No;
public void sayMyName(){
System.out.println("我的名字叫:"+name);
}
public void study(){
System.out.println("我正在学习java");
}
}
public class Student{
public String name;
public int age;
public String no;
public void sayMyName() {
System.out.println("我会叫:" + name);
}
public void study() {
System.out.println("我正在学习JAVA");
}
}
希望能帮到你
public class Student {
public String name;
public Integer age;
public String no;
public void sayMyName(){
System.out.println("我会叫"+name);
}
public void study(){
System.out.println("我正在学习java");
}
public static void main(String[] args){
Student s = new Student();
s.name = "张三";
s.sayMyName();
s.study();
}
}
结果
我会叫张三
我正在学习java
public class Student {
public String name;
public int age;
public int NO;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getNO() {
return NO;
}
public void setNO(int nO) {
NO = nO;
}
public void sayMyName(){
System.out.println("我会叫" + name);
}
public void study(){
System.out.println("我正在学习JAVA");
}
}
使用的是默认包
PS:我也是刚学习
public class Student {
public String name;
public int age;
public int no;
public Student(String name, int age, int no){
this.name = name;
this.age = age;
this.no = no;
}
public void sayMyName(){
System.out.println("我会叫" + name);
}
public void study(){
System.out.println("我正在学习JAVA");
}
public static void main(String[] args) {
Student student = new Student("小明", 18, 1001);
student.sayMyName();
student.study();
}
}