File tree 1 file changed +41
-0
lines changed
1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -284,6 +284,47 @@ Java 中的注释有三种:
284
284
1. `return ;` :直接使用 return 结束方法执行,用于没有返回值函数的方法
285
285
2. `return value;` :return 一个特定值,用于有返回值函数的方法
286
286
287
+ 思考一下:下列语句的运行结果是什么?
288
+
289
+ ```java
290
+ public static void main(String [] args) {
291
+ boolean flag = false ;
292
+ for (int i = 0 ; i <= 3 ; i++ ) {
293
+ if (i == 0 ) {
294
+ System . out. println(" 0" );
295
+ } else if (i == 1 ) {
296
+ System . out. println(" 1" );
297
+ continue ;
298
+ } else if (i == 2 ) {
299
+ System . out. println(" 2" );
300
+ flag = true ;
301
+ } else if (i == 3 ) {
302
+ System . out. println(" 3" );
303
+ break ;
304
+ } else if (i == 4 ) {
305
+ System . out. println(" 4" );
306
+ }
307
+ System . out. println(" xixi" );
308
+ }
309
+ if (flag) {
310
+ System . out. println(" haha" );
311
+ return ;
312
+ }
313
+ System . out. println(" heihei" );
314
+ }
315
+ ```
316
+
317
+ 运行结果:
318
+ ```
319
+ 0
320
+ xixi
321
+ 1
322
+ 2
323
+ xixi
324
+ 3
325
+ haha
326
+ ```
327
+
287
328
### 方法
288
329
289
330
#### 什么是方法的返回值?方法有哪几种类型?
You can’t perform that action at this time.
0 commit comments