パーソナルブログメモリ

a = [1, 1]
for _ in "*" * 999: a += [sum(a[-2:])]
print(a)

Javaの連想配列(辞書型)のサンプル

2021-04-24 | プログラムをマスター計画2021

イメージ

 

CodinGameのエディタからコピペ。

インデントはくずれる

import java.util.*;
class Player {
public static void main(String args[]) {
Map<Integer, Integer> floorPos = new HashMap<>(); //連想配列の定義 intで定義できない
floorPos.put(20, 50); //追加
int t = 21;
floorPos.put(t, t); //追加 intでもできる intのラッパークラスがIntegerだそうな
System.err.println(floorPos.get(20)); // 取得 50
System.err.println(floorPos.get(21)); // 取得 21
System.err.println(floorPos.get(22)); // 取得 ない時 null
}
}
 

最新の画像もっと見る

コメントを投稿

ブログ作成者から承認されるまでコメントは反映されません。