Java

Socketから送られてくるUTF-8なデータをScala(Java)のUnicodeで使う。

ScalaでUTF-8な文字コードが設定されているIRCサーバ(のチャンネル)と通信したいときなど、エンコーディングが統一されていない場合はInputStreamReaderを頼って第二引数に文字コードを指定しましょう。 import java.io._ val in = new BufferedReader(new…

Question: double synchronized statement for one reference

Do you think this causes deadlock? class Hello { public static void main(String[] args) { Hello t = new Hello(); synchronized(t) { synchronized(t) { System.out.println("made it!"); } } } } Answer 14.19 The synchronized Statement

Question of return statement in finally clause in Java

What do you think would happen? public class Hello { public static void main(String[] args) { System.out.println("Result: " + func()); } private static int func() { try { return 1; } catch (Exception e) { return 2; } finally { return 3; } …