标签:test protect 封装 ext pack rgs his protected 对象
面向对象的基本概念
1,对象
2,类
3,封装
4,继承
5,消息
6,多态性
优点
1,符合人们认识事物的规律
2,改善了程序的可读性
3,使人机交互更加贴近自然语言
1 package Com.TableTest; 2 3 public class TableText_19 { 4 public static void main(String[] args){ 5 Circle c=new Circle(2,"borter"); 6 System.out.println(c.name); 7 c.Circle(); 8 } 9 } 10 class Shape { 11 12 protected String name; 13 14 public Shape(){ 15 name = "shape"; 16 } 17 18 public Shape(String name) { 19 this.name = name; 20 } 21 } 22 23 24 class Circle extends Shape { 25 26 private double radius; 27 28 public Circle() { 29 radius = 0; 30 } 31 32 public Circle(double radius) { 33 this.radius = radius; 34 35 } 36 37 public Circle(double radius,String name) { 38 this.radius = radius; 39 this.name = name; 40 } 41 void Circle(){ 42 System.out.println(this.radius); 43 } 44 }
标签:test protect 封装 ext pack rgs his protected 对象
原文地址:https://www.cnblogs.com/borter/p/9393413.html