無料で使えるシステムトレードフレームワーク「Jiji」 をリリースしました!

・OANDA Trade APIを利用した、オープンソースのシステムトレードフレームワークです。
・自分だけの取引アルゴリズムで、誰でも、いますぐ、かんたんに、自動取引を開始できます。

配列の中身をさくっと文字列にする

配列だとtoString()とかできないので、(これも原罪というやつか)

String[] strs = new String[]{ "a", "b", "c" };
System.out.println( strs != null ? Arrays.asList( strs ) : "null" );

とかいう感じで書いていたのだけど、Arrays.deepToString()とかあるじゃないか。

import static java.util.Arrays.deepToString;
...
String[] strs = new String[]{ "a", "b", "c" };
System.out.println( deepToString( strs ) );

strs = null;
System.out.println( deepToString( strs ) );

// ネストされた配列もOK
String[][] strs2 = new String[][] {
    new String[]{ "a", "b", "c" },
    new String[]{ "x" },
    null
};
System.out.println( deepToString( strs2 ) );

実行結果です。

[a, b, c]
null
[[a, b, c], [x], null]

そういえばArrays#deepEqualsは前に使ったなー。