package com.dongchao; |
02 | class Person |
03 | { |
04 | String name; |
05 | int age; |
06 | } |
07 | class Student extends Person |
08 | { |
09 | void study() |
10 | { |
11 | System.out.println( "...study..." ); |
12 | } |
13 | } |
14 | |
15 | class Worker extends Person |
16 | { |
17 | void work() |
18 | { |
19 | System.out.println( "...work..." ); |
20 | } |
21 | } |
22 | class ExtendsDemo { |
23 | public static void main(String[] args) |
24 | { |
25 | Student stu = new Student(); |
26 | stu.name = "xiaoming" ; |
27 | System.out.println(stu.name); |
28 | } |
29 | } |
文章来源:学什么网