0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

JavaのMapと使いどころ

Posted at

Mapとは

「キー」と「値」をペアにして複数の値を格納できるもの

Mapの種類

Mapはインタフェースなので実装クラスを用意して使う必要がある。
実装クラスにはHashMap,LinkedHashMap,TreeMapなどがある。

Mapのメソッド

1.putメソッド Mapにデータを追加

2.getメソッド Mapからデータを取得

3.keySetメソッド Mapのすべてのキーを出力

こんな時に使える

・大量の何かをキーと紐づけて回すとき。

ex.aからzまでの26文字を追加する

Map<Character,Integer> atozMap = new HashMap<>() {
        	{
        	
        		for(char c = 'a';c < 'z'+1;c++) {
        			put(c,0);
        		}
        	}
        };
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?