Javaコレクションフレームワークの、クラス型とインタフェース型の使い分けについてですが、
newで作ったインスタンスを、
クラス型に代入する場合と、インタフェース型に代入する場合があるのですが、どちらを優先して使ったほうがいいですか?
※物によっては、インタフェース型しかつかえないとか、どちらでも良い場合とかいろいろあると思います。
また、インタフェース型のほうがメソッドの種類が若干多いですが、抽象メソッドなのでオーバーライドして使うからそれは関係ないのかな。
・本に出てきた例
ArrayList<E> list = new ArrayList<E>();
List<E> list = new ArrayList<E>();
Queue<E> queue = new LinkedList<E>();
LinkedList<E> list = new LinkedList<E>();
LinkedList<E> stack = new LinkedList<E>();
Set<E> set = new HashSet<E>();
Map<E, M> map = new HashMap<E, M>();
以下の英文がうまく訳せません。
どなたかうまく訳せる方はいらっしゃいますか?
甲虫のツノのでき方について説明している一文です。
よろしくお願いします。
The size threshold a male larva must reach in order to produce horns and the longest and shortest possible horns in larvae that reach this threshold .
こんにちは。
よろしくお願いいたします。
Aさん「近頃どうも体の調子がおかしくてね。」
Bさん「一度見てもらったほうがいいよ。」
を英作文すると。。。
I haben't been feeling good.
You should see a doctor.
If you notice any grammtical mistake, please correct it, and let me know any other expression you can imagine of which possibly exceeds one already in this document! thank you!
こんにちは。
よろしくお願いいたします。
Aさん「近頃どうも体の調子がおかしくてね。」
Bさん「一度見てもらったほうがいいよ。」
を英作文すると。。。
I haben't been feeling good.
You should see a doctor.
If you notice any grammtical mistake, please correct it, and let me know any other expression you can imagine of which possibly exceeds one already in this document! thank you!