println vs System.out.println in Scala
我一直认为
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | scala> val baos = new java.io.ByteArrayOutputStream baos: java.io.ByteArrayOutputStream = scala> val ps = new java.io.PrintStream(baos) ps: java.io.PrintStream = java.io.PrintStream@6c5ac4 scala> System.setOut(ps) scala> println("hello") hello scala> new String(baos.toByteArray) res2: java.lang.String ="" scala> System.out.println("hello") scala> new String(baos.toByteArray) res7: java.lang.String = "hello " |
另外,当system.setout时,
1 2 3 4 5 6 7 |