diff --git a/03:类与对象/01.md b/03:类与对象/01.md index 5429309..9927c18 100644 --- a/03:类与对象/01.md +++ b/03:类与对象/01.md @@ -180,9 +180,16 @@ public class Circle_Test { } ``` +> A class may be defined without constructors. In this case, a no-arg constructor with an empty body is implicitly defined in the class. This constructor, called a default constructor, is provided automatically only if no constructors are explicitly defined in the class. + 如果你写了一个带参数的构造函数,建议写一个不带参数的构造函数,这样会省掉很多麻烦,后面会讲述。关于构造函数,会在后面的学习中详细讲述。 -**注意,构造函数不能声明为私有的,不能声明为静态的,不能写返回参数!** +**注意,构造函数一般不声明为私有,不能声明为静态的,不能写返回参数!** + +其他的一些例子: + +1. TestSimpleCircle +2. TestTv @@ -235,6 +242,11 @@ if (c1 == null) { // 可以判断一个引用变量是否没有被赋值 } ``` +SDK中的一些类: + +1. The Random Class +2. The Point2D Class + ## 4. 类的成员 @@ -255,6 +267,8 @@ if (c1 == null) { // 可以判断一个引用变量是否没有被赋值 下面的例子中在`CircleWithStaticMembers`这个类中定义了一个静态变量`static int numberOfObjects = 0;`用来统计`CircleWithStaticMembers`这个类一共被创建出了几个对象。 +![image-20250312141800266](./img/image-20250312141800266.png) + ```java class CircleWithStaticMembers { double radius; @@ -509,6 +523,8 @@ public class Test { 下面看看数组中的元素是引用类型的情况,借用上个例子的`CircleWithPrivateDataFields`类型。 +![image-20250312141956130](./img/image-20250312141956130.png) + ```java public class TotalArea { /** Main method */ diff --git a/03:类与对象/img/image-20250312141800266.png b/03:类与对象/img/image-20250312141800266.png new file mode 100644 index 0000000..554e4e9 Binary files /dev/null and b/03:类与对象/img/image-20250312141800266.png differ diff --git a/03:类与对象/img/image-20250312141956130.png b/03:类与对象/img/image-20250312141956130.png new file mode 100644 index 0000000..bbf5188 Binary files /dev/null and b/03:类与对象/img/image-20250312141956130.png differ