Information technologies

New world
Site quantity is over 200 million. 3 billion internet users out there. Internet-auctions, web-sites, online shops, internet-services. Information Technology industry grows 20%-30% annually. It is monstrous rates. And it keeps growing. For the last 10 years in Silicon Valley (the main center of high-tech industry of the world), each 2 month a company is created, which afterwards costs the billions of dollars. Not to mention about such internet stars as Facebook ($220 billion), Amazon ($140 billion) and Google ($350 billion). All these companies would not appear, if there was no Internet. All of it results in high demand on IT-specialists. World high-tech industry requires: software developers, designers, QA testers, architects, managers, system administrators and other specialists.It’s good to be an IT specialist

You have reached a new level
Level 7

1 Elly, Arrays
- Hey, Amigo! - What’s up, Elly? - Today I’ll tell you about a new interesting entity - arrays. An array is a special data type that can store more than one value.
TypeName[] variable_name
instead of TypeName variable_name
.
- Here are examples what you can do with arrays:


- The array consists of multiple cells.
- Every cell is accessed by indicating its number.
- All the cells are of the same type.
- In an array of n elements, the cells have indexes 0,1,2,...,n-1. There is no cell with index n in the array.
- The initial value for all the cells is null, for primitive types – 0, 0.0 for fractional ones, false - for boolean type, exactly the same as in simple uninitialized variables.
- String[] list is just a declaration of a variable. First you need to create an array (container) and put it in the variable, and then use it. See the example below.
- When you create an object array (container), it’s necessary to specify its length (how many cells it will have). To do this you need to write a command:
new TypeName[n];
TypeName is the type of values which will be stored in cells of the array.


2 Risha, Arrangement of arrays in memory
- Hey, Amigo! Let me show you how it all works in the memory:

3 Risha, Examples of arrays Array
- I want to give you a few examples of interesting things you can do with arrays: Example 1.




4 Diego, Tasks for creation and use of arrays
- Hey, Amigo! Here’s a couple of tasks for you, buddy:Tasks | |
---|---|
1 | 1. Maximum of an array of 20 numbers 1. In the method initializeArray(): 1.1. Create an array of 20 numbers 1.2. Read from the keyboard 20 numbers and fill the array with them 2. The method max(int[] array) should find the maximum number of the elements of the array |
2 |
2. Array of strings in reverse order |
3 | 3. 2 arrays 1. Create one array of 10 strings. 2. Create another array of 10 numbers. 3. Read from the keyboard 10 strings and fill the string array with them. 4. Write the length of a string from each cell of the string array in the cell of numbers array with the same index. Display to the screen the contents of the array of numbers. Each value should be on a new line. |
4 | 4. Array of numbers in reverse order 1. Create an array of 10 numbers. 2. Read from the keyboard 10 numbers and store them in the array. 3. Arrange array elements in reverse order. 4. Display to the screen the result. Each value should be on a new line. |
5 | 5. One large and two small arrays 1. Create an array of 20 numbers. 2. Read from keyboard 20 numbers and fill the array with them. 3. Create two arrays of 10 numbers each. 4. Copy numbers of the large array to two small arrays: the half of the numbers to the first array, the other half to the second one. 5. Display to the screen the second small array. Each value should be on a new line. |
5 Elly, ArrayList vs. Array
- It’s me. - Hi, Elly! - Today we have a new exciting topic! Now I’ll tell you about an interesting new class, the ArrayList. - Oh, a new class? Wow! What does it do? - Let me begin with a little back story. The programmers didn’t like one property of an array: it is impossible to change its size. What to do if you want to store three entries more in the array, but there’s only one free space? - The only solution to the lack-of-space problem was to create a very large array that contains all the elements. But this often led to inefficient usage of memory. For example, if in 99% of array lifetime you needed to store only 3 elements in array, and just in 1% - 100 elements, you would have to create array of 100 elements. - So what did the programmers come up with? - They wrote the class ArrayList that did the same job as the Array, but could vary its size. - An interesting move. And how did they do that? - Every ArrayList object stores an ordinary array of elements inside. When you read elements from the ArrayList, it reads them from its internal array. When you write the elements, it writes them to the internal array. Compare:
- another one array is created, twice as large.
- all the elements of the old array are copied to the new array.
- a new array is stored in an internal variable of the ArrayList object, the old array is declared garbage (we simply don’t store its reference any more).


6 Diego, ArrayList tasks
- Are you doing nothing again? You’re a robot, aren’t you? Robots are always busy with something. Here are some tasks to keep you up. But let’s begin with a couple of tips. - Tip 1: A list most commonly means an ArrayList. - Tip 2: A string means the type String. - Tip 3: To create a list of strings most commonly means ArrayList<String> list = new ArrayList<String>();Tasks | |
---|---|
1 |
Task 1. 5 different strings in a list 1. Create a list of strings. 2. Add 5 different strings to the list. 3. Display to the screen its size. 4. Display to the screen contents of the list. Each value should be on a new line. Use a loop. |
2 | Task 2. 5 lines: «101», «102», «103», «104», «105» 1. Create a list of strings. 2. Add 5 strings to the list. «101», «102», «103», «104», «105». 3. Delete the first one, the middle one and the last one. 4. Display to the screen contents of the list. Each value should be on a new line. Use a loop. 5. Display to the screen its size. (After deleting one entry, the indexes of other entries change. For instance, if we delete first element, the second becomes the first one). |
3 |
Task 3. 5 lines in reverse order 1. Create a list of strings. 2. Read 5 strings from keyboard, then add them to the list. 3. Arrange them in reverse order. 4. Display to the screen contents of the list. Each value should be on a new line. Use a loop. |
4 |
Task 4. Add 5 strings to the beginning of the list |
5 |
Task 5. Delete the last string and add it to the beginning of the list 1. Create a list of strings. 2. Read from keyboard 5 strings. Add these strings to the list. 3. Delete the last string and add it to the beginning of the list. Repeat this action 13 times. 4. Display to the screen contents of the list. Each value should be on a new line. Use a loop. |
7 Risha, Generics
- Now, another awesome topic. - This day is full of surprises. It’s like a real birthday. - Today I’ll tell you what Generics are. Generics are types that have parameters. In Java, container classes enable you to specify types of their internal objects. - When we declare a generic variable, we specify two types instead of one: the type of the variable and the type of data stored in the variable. A good example of this is ArrayList. When we create a new object/variable of ArrayList type, it’s also good to specify type of values to be stored inside the list.


8 Risha, Examples of ArrayList, Generics






9 Diego, List<T> tasks
- Finally you are free. I’m tired of keeping in mind these tasks for you. Here’s a couple more to keep you up:Additional tasks to do in Intellij Idea | |
---|---|
1 |
1. Three arrays 1. Read from the keyboard 20 numbers, save them in a list, then sort them into three other lists: List 1 stores numbers divisible by 3 (x%3==0) List 2 stores numbers divisible by 2 (x%2==0) List 3 stores the rest of numbers. The numbers divisible by 3 and 2 at the same time (for example 6) belong to both lists – list 1 and list 2. 2. The method printList() should display each element of the list on a new line. 3. Use the method printList() to display to the screen these three lists. First the list 1 should be displayed, then list 2, after that list 3. |
2 |
2. 5 words in reverse order Read from the keyboard 5 words. Add them into a string list and display them to the screen in reverse order. |
3 |
3. The word «here» 1. Create a list of the words «stop», «look», «listen». 2. Add a string containing «here» after each word. 3. Display the result. Each element of list should be on a new line. Use “for” loop. |
4 |
4. Letters «r» and «l» 1. Create a list of words/strings, fill it with whatever you want. 2. The method fix() should: 2.1. delete all the words containing letter «r» from the list of strings 2.2. double all the words containing letter «l». 2.3. leave the word unchanged if it contains both letters «r» and «l». 2.4. don’t do anything with other words. Example: rose willow lyre oak Output data: willow willow lyre oak |
5 |
5. Duplicate the words 1. Read from the keyboard 10 words/strings, add them into a string list. 2. The method doubleValues should duplicate words according to the pattern: a,b,c → a,a,b,b,c,c. 3. Display the result. Each element of list should be on a new line. Use “for” loop. |
10 Professor

11 Julio
- Hey, Amigo! I’m glad you’ve coped with all this - you deserve a reward:12 Captain Squirrels
- Hello, soldier! - Good morning, sir! - I have some awesome news for you. Here’s a quick check to reinforce your skills. Do it every day, and you’ll enhance your skills real quick. Tasks are specially designed to do in Intellij IDEA.Additional tasks to do in Intellij Idea | |
---|---|
1 |
1. Display numbers in reverse order Read from the keyboard 10 numbers and fill the list with them. Display to the screen the numbers in reverse order. Use the loop. |
2 |
2. Move first M lines to the end of the list Read from the keyboard 2 numbers: N and M. Read from keyboard N strings and fill a list with them. Move first M lines to the end of the list Display to the screen the list. Each value should be on a new line. |
3 |
3. Largest and smallest number in an array Create an array of 20 numbers. Fill it with numbers that are read from keyboard. Find the largest and smallest number in an array. Display to the screen the largest and smallest numbers separated by a space. |
4 |
4. Read strings from the keyboard until user enters the string “end” Create a list of strings. Read from the keyboard strings (whatever you want), add them to the list. Read strings from the keyboard until user enters the string “end”. “end” should be omitted. Display to the screen the strings. Each string should be on a new line. |
5 |
5. Bang! Write a program that counts down from 30 to 0, and displays «Bang!» at the end. The program should reduce the number 10 times per second. Use the function below to insert a delay: Thread.sleep(100); //delay of one tenth of a second. Example: 30 29 … 1 0 Bang! |
6 |
6. Family Create a class Human with the fields: String name, boolean sex, int age, Human father, Human mother. Create 9 objects of Human class and fill them in such a way as to obtain two grandfathers, two grandmothers, a father, a mother, and three children. Display to the screen the objects to the screen. Tip: If you write your method String toString() in the class Human, then it’ll be used to display an object. Example output: Name: Anna, sex: female, age: 21, father: Paul, mother: Kate Name: Kate, sex: female, age: 55 Name: Ian, sex: male, age: 2, father: Michael, mother: Anna … |
7 |
7. Move one modifier static Move one static modifier so the program compile. |
Bonus tasks | |
---|---|
1 |
1. Program doesn’t compile and run. Fix it. Task: Read from the keyboard the cat data and display it to the screen. Example: Cat name is Jinx, age is 6, weight is 5, tail = 22 Cat name is Maisy, age is 8, weight is 7, tail = 20 |
2 |
2. Add new functionality to the program. Old Task: The program reads strings until the user enters a blank line by pressing enter. Then it converts lower-case into upper-case (Mom turns into MOM) and displays them on the screen. New task: The program should read strings until the user enters a blank line by pressing enter. The program then builds a new list. If the string has an even number of characters, the string is duplicated, if odd number, the string is tripled. Example input: Cat Cats Me Example output: Cat Cat Cat Cats Cats Me Me |
3 |
3. Learning and practicing algorithm. Read from the keyboard 20 numbers and display them in descending order. |
GO TO FULL VERSION