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?

【ResponseEntity<Map<String, String>> とは?】

Posted at

ResponseEntity<Map<String, String>>
これは「HTTPレスポンスを返すためのオブジェクト」です。そして中に含まれているのは Map(連想配列)形式のデータ です!

ResponseEntity<>
Spring Frameworkのクラスで、HTTPステータスコード、ヘッダー、ボディを含むレスポンスを構成できる

たとえば、ResponseEntity.ok() で「HTTP 200 OK」というステータスを意味します!

Map<K, V>

Map<String, String>
これはJavaの「キーと値のペア」を表すデータ構造で、String型のキーと値を持つMap。

JavaのMapは、キー(Key)と値(Value)をセットで管理するデータ構造です。そのため、次のように型(データの種類)を2つ指定します:

最初のString → キーの型(たとえば "message")

2つ目のString → 値の型(たとえば "スレッドを消しました")

つまり Map<String, String> は:「キーも値もどちらも文字列(String)です」

という意味になります。

他の例を出すと…

Map<Integer, String>

だと、「キーが整数(例: 101)、値が文字列(例: "スレッドタイトル")」という感じになります。

まとめると: 2つの String は、それぞれ「キーの型」と「値の型」なんです。セットで覚えておくと、他のジェネリクス型でも応用できるようになr

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?