student3.java~2~
来自「提供了常用的JAVA技术的示例」· JAVA~2~ 代码 · 共 34 行
JAVA~2~
34 行
package Student3;class Date{ int year; int month; int day; Date(int year,int month,int day){ this.year=year; this.month=month; this.day=day; } void showDate(){ System.out.println(year+"-"+month+"-"+day); }}public class Student3 { String no; String name; Date birth; // 对象变量作类的成员,莫认初始值为 null void setStu(String s1,String s2,int y,int m,int d){ no=s1; name=s2; birth=new Date(y,m,d); } Date getBirth(){ return birth; }public static void main(String[] args) { Student3 stu=new Student3(); stu.setStu("sun","xiaomei",1977,12,27); System.out.print(no+name+"'s birth is"); stu.getBirth().showDate(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?