LoginSignup
0
0

More than 3 years have passed since last update.

java 組合せ(ArCombination)の生成

Posted at

目次 ⇒ Javaアルゴリズムライブラリ-Artery-サンプル

package jp.avaj.lib.algo;

import java.util.List;

import jp.avaj.lib.test.L;

/**
組合せ(ArCombination)

組合せを生成するには、ArCombinationクラスを使用する.
本サンプルでは季節(ArSeason)から二つの組合せを取得する.
 */
public class Q08_00 {
  public static void main(String[] args) {

    ArCombination<ArSeason> combi = new ArCombination<ArSeason>(ArSeason.values());

    // 組合せを生成する
    List<List<ArSeason>> list = combi.create(2);
    // 結果を確認する
    for (List<ArSeason> item : list) {
      L.p("item="+item.toString());
    }
  }
}

result.txt
item=[春, 夏]
item=[春, 秋]
item=[春, 冬]
item=[夏, 秋]
item=[夏, 冬]
item=[秋, 冬]

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0