以下のコードでは、要素を 1 回だけ呼び出します。すべてが削除され、残りの要素が1つしかないときに、「これは配列リストの最後の要素です」と出力するにはどうすればよいですか。
ArrayList<String> Responselist = new ArrayList<String>();
Responselist.add(CommentResponse());
Responselist.add(TriviaResponse());
Responselist.add(CriticResponse());
String[] SelectRand = new String [3];
for (int i = 0; i < SelectRand.length; ++i)
{
int rnd = (int) (Math.random() * Responselist.size());
SelectRand[i] = Responselist.get(rnd);
Responselist.remove(rnd);
}
for (String x : SelectRand)
{
if (!(Responselist.isEmpty()))
{
System.out.println(x);
}
}