|
1
static void method(int a,int b){
System.out.println("a=100,b=200"); //throw new NullPointerException(); System.exit(0); } |
|
finalspeedFeb 10, 2017
2
楼上的 66666....
|
|
kaka8wpFeb 10, 2017
3
楼上的 66666....
|
|
fighter2011Feb 10, 2017
4
等待其他解答
|
|
ininitFeb 10, 2017 via Android
5
楼上的 666
|
|
qiayueFeb 10, 2017
6
@ArthurKing exit 哈哈哈
|
|
7
跟你们说吧,只有 1 楼的答案是对的,因为后面那两个它么是的 println (笑哭
|
|
ArthurKingFeb 10, 2017
8
@bianhua 不不不,还可以换成 while(true); ( ˙-˙ )
|
|
happyylFeb 10, 2017 via Android
9
楼上的 66666....
|
|
jasontseFeb 10, 2017 via iPad
11
套路。。。
|
|
haozibiFeb 10, 2017
12
1 楼真是简单粗暴
|
|
vh2hFeb 10, 2017
13
自古一楼出奇迹,看来没错啊!膜拜一楼。
|
|
aitaiiFeb 10, 2017 via Android
14
正常的话是 a
b |
|
aristotllFeb 10, 2017
15
第二种方法是啥 第一种我也想到了...
|
|
16
|
|
valkyrjaFeb 10, 2017 via Android
17
似乎可以覆盖 system.out.println 然后 replace?
|
|
18
长知识,帮补代码:
public static void method(int a, int b) { System.setOut(new PrintStream(System.out) { @Override public void println(String s) { super.println(s.equals("a=10") ? "a=100" : "b=200"); } }); } |
|
lxy42Feb 11, 2017 via Android
19
在 method 中打印结果后,将 stdout 重定向到 stderr
|
|
flyingghostFeb 11, 2017
21
```
public static void method(int a, int b){ final PrintStream oldOut = System.out; PrintStream ps=new PrintStream(new FilterOutputStream(oldOut) { boolean meetOne = false; @Override public void write(int b) throws IOException { if( b =='0'){ oldOut.write('0'); oldOut.write(b); } else if(b == '1'){ if(!meetOne){ meetOne = true; oldOut.write(b); } else { oldOut.write('2'); } } else { oldOut.write(b); } } }); System.setOut(ps); } ``` |