Skip to content

Commit ea6dfe3

Browse files
committed
一道有趣的百度题
1 parent 5051b85 commit ea6dfe3

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

bin/com/baidu/PrintAB.class

764 Bytes
Binary file not shown.

src/com/baidu/PrintAB.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.baidu;
2+
3+
public class PrintAB {
4+
public static void main(String[] args) {
5+
new PrintAB().printAB();
6+
}
7+
8+
/**
9+
* 这个解法自己想的有点弱智了!
10+
*/
11+
// public void printAB(){
12+
// if(new PrintAB(){
13+
// boolean www(){
14+
// System.out.print("a");
15+
// return false;
16+
// }
17+
// }.www()){
18+
// System.out.print("a");
19+
// }else{
20+
// System.out.print("b");
21+
// }
22+
// }
23+
24+
/**
25+
* 借鉴的解法
26+
*/
27+
public void printAB(){
28+
if(System.out.append("a")==null){
29+
System.out.print("a");
30+
}else{
31+
System.out.print("b");
32+
}
33+
}
34+
35+
36+
}

0 commit comments

Comments
 (0)