1
ArthurKing Feb 10, 2017 static void method(int a,int b){
System.out.println("a=100,b=200"); //throw new NullPointerException(); System.exit(0); } |
2
finalspeed Feb 10, 2017
楼上的 66666....
|
3
kaka8wp Feb 10, 2017
楼上的 66666....
|
4
fighter2011 Feb 10, 2017
等待其他解答
|
5
ininit Feb 10, 2017 via Android
楼上的 666
|
6
qiayue PRO @ArthurKing exit 哈哈哈
|
7
bianhua Feb 10, 2017 跟你们说吧,只有 1 楼的答案是对的,因为后面那两个它么是的 println (笑哭
|
8
ArthurKing Feb 10, 2017
@bianhua 不不不,还可以换成 while(true); ( ˙-˙ )
|
9
logbang Feb 10, 2017 via Android
楼上的 66666....
|
11
jasontse Feb 10, 2017 via iPad
套路。。。
|
12
haozibi Feb 10, 2017
1 楼真是简单粗暴
|
13
vh2h Feb 10, 2017
自古一楼出奇迹,看来没错啊!膜拜一楼。
|
14
aitaii Feb 10, 2017 via Android
正常的话是 a
b |
15
aristotll Feb 10, 2017
第二种方法是啥 第一种我也想到了...
|
16
virusdefender Feb 10, 2017 via iPhone |
17
valkyrja Feb 10, 2017 via Android
似乎可以覆盖 system.out.println 然后 replace?
|
18
padeoe Feb 11, 2017 长知识,帮补代码:
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"); } }); } |
19
lxy42 Feb 11, 2017 via Android
在 method 中打印结果后,将 stdout 重定向到 stderr
|
21
flyingghost Feb 11, 2017
```
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); } ``` |