File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -1323,6 +1323,55 @@ public static void main(String[] args) {
1323
1323
应该注意的是,返回值不同,其它都相同不算是重载。
1324
1324
1325
1325
1326
+ - 方法重载 例子
1327
+ ``` java
1328
+ class DisplayOverloading
1329
+ {
1330
+ public void disp (char c )
1331
+ {
1332
+ System . out. println(c);
1333
+ }
1334
+ public void disp (char c , int num )
1335
+ {
1336
+ System . out. println(c + " " + num);
1337
+ }
1338
+ }
1339
+ class Sample
1340
+ {
1341
+ public static void main (String args [])
1342
+ {
1343
+ DisplayOverloading obj = new DisplayOverloading ();
1344
+ obj. disp(' a' );
1345
+ obj. disp(' a' ,10 );
1346
+ }
1347
+ }
1348
+ ```
1349
+ [ Method Overloading] ( https://beginnersbook.com/2013/05/method-overloading/#:~:text=Method%20Overloading%20is%20a%20feature,constructor%20having%20different%20argument%20lists. )
1350
+
1351
+ - 构造重载 例子
1352
+ ``` java
1353
+ class DisplayOverloading
1354
+ {
1355
+ DisplayOverloading (char c )
1356
+ {
1357
+ System . out. println(c);
1358
+ }
1359
+ DisplayOverloading (char c , int num )
1360
+ {
1361
+ System . out. println(c + " " + num);
1362
+ }
1363
+ }
1364
+ class Sample
1365
+ {
1366
+ public static void main (String args [])
1367
+ {
1368
+ DisplayOverloading obj = new DisplayOverloading (' a' );
1369
+ DisplayOverloading obj2 = new DisplayOverloading (' a' ,10 );
1370
+ }
1371
+ }
1372
+ ```
1373
+ [ Constructor Overloading] ( https://beginnersbook.com/2013/05/constructor-overloading/ )
1374
+
1326
1375
# 七、反射
1327
1376
1328
1377
每个类都有一个 ** Class** 对象,包含了与类有关的信息。当编译一个新类时,会产生一个同名的 .class 文件,该文件内容保存着 Class 对象。
You can’t perform that action at this time.
0 commit comments