「また何もせずに座っているのですか? あなたはロボットです! ロボットはいつでも何かをしています。ここでは、あなたを錆びさせないためのいくつかの演習を紹介します。しかし、その前に、いくつかのヒントを示します。」
「ヒント1:
「リスト」とは通常、ArrayListを意味します。
「ヒント2:
「文字列」はStringオブジェクトを意味します。
「ヒント3:
「文字列のリストを作成する」は、ほとんどの場合次のことを意味します。ArrayList<String> list = new ArrayList<String>(); 」
2
タスク
Java Syntax, レベル 7, レッスン 6
What sort of list is that?
Java programmers love their lists just as much as conscientious homemakers love their shopping lists and to-do lists. If you haven't fallen in love with them yet, it's time to start. And a programmer's love begins with code. So, in this task, we'll create a list of strings, add 5 different strings, and then display the size of the list on the screen. Then we'll display the contents of the list. Easy peasy!
10
タスク
Java Syntax, レベル 7, レッスン 6
Longest string
Let's measure strings! And we'll complete a programming task at the same time: create a string list, read 5 strings from the keyboard, and add them to the list. Then use a loop to find the longest string (or longest strings, if there is more than one). A country should know its heroes: the longest strings will be displayed.
5
タスク
Java Syntax, レベル 7, レッスン 6
Expressing ourselves more concisely
Brevity is the soul of wit. In the this task, let's celebrate brevity by doing the following: create a list, read 5 strings from the keyboard, add them to the list, find the shortest string, and then display it. If several strings are shortest, we'll display them all, each on a new line. Any questions, private?!
2
タスク
Java Syntax, レベル 7, レッスン 6
To the top of the list
Imagine people making appointments at a dental office where the waiting list acts like a stack rather than a queue: the last person to schedule is the first to have a drill taken to his or her tooth. We'll write a program that reflects this unusual situation: create a list and add 10 strings, but we'll add them to the beginning of the list rather than the end.
5
タスク
Java Syntax, レベル 7, レッスン 6
Remove and insert
Manipulating lists in Java is almost as easy and enjoyable as manipulating people! Anyway, about those lists. Here's what you need to do: create a list and add 5 strings. Then remove the last string and insert it at the beginning. Repeat this manipulation 13 times and then display the contents of the list. Why? Don't ask, just believe: it's necessary.
10
タスク
Java Syntax, レベル 7, レッスン 6
Shortest or longest
Java games with lists are very popular. This makes sense, since they are all so simple and interesting. Join in the fun! In this task, we create a list of strings. Then we add 10 strings from the keyboard. The most interesting part is that we'll determine whether the shortest string or the longest string is encountered first in the list. If more than one string is shortest or longest, we'll consider the very first one we encounter.