CodeGym
Level 41

Old Level 08

Published in the Java Developer group
members

Global labor market

Old Level 08 - 1If you live in a little, poor or developing country you may bump into limitedness of local labor market at some point.

Limitations for local labor market

1 Low salary

Even if you are a highly-qualified specialist there may simply be no employer able to pay you the salary you deserve on the local labor market. Example: teachers, scientists.

2 Unnecessary college degrees

The quantity of lawyers and economists universities produce exceeds the labor market demand more ten times. 90% of those specialists can’t get work on profession. Often it’s the result of low education quality.

3 No demand for your profession

You may be a wonderful scientist, but state no longer finances fundamental researches. In labor registry office you are being advised to re-qualify. In such situation to do this is very unwise, because there are some countries where your knowledge and skills are in demand. When a world-renown scientist leaves him native cathedra and settles for washing dishes in New-York – it’s a tragedy. When a world-renown scientist washes dishes in his own country instead of being head of cathedra in New-York – it’s an even greater tragedy.

4 Little career opportunities

You are a stock exchange broker and you wish to advance as focused specialist on financial credit funds. You wish to be the head of your own investment foundation in the future. There can be no demand for such specialists as you in your country.

5 Small labor markets

In your country there may be only two companies interested in a specialist like you. If you work for one of them, you may be forbidden from working with their rivals. You simple have no place to go. Globalization process and development and cheapening of telecommunication techniques resulted into global labor market appearance. Global market consists of companies which are willing (and able) to hire employers abroad. It also consists of employers willing (and able) of getting a job in the foreign company.

Advantages of global labor market

1 Salaries are lower than in developed countries, but higher that in developing ones

If you are from developing country and you are a specialist on demand on global labor market, than your salary can differ 5-10 times on global market and on local one. What’s more you get to spend your money in your country, pouring it into its economy.

2 Experience. Superior business-process

There are three most important things your job provides you with: experience, money and connections. If you’re used to taking just money – that’s your problem. You can get most valuable experience if you work for world’s lead companies. They welcome globalization tendencies, so to get a job there is easier than you think. When you are a company’s employee you have an opportunity to see all effective and ineffective internal business processes. All you need to do is watch and listen.

3 Big career opportunities

A job in a big international corporation will help you grow professionally and build a career. You may get good connections all over the world, and that’s very useful: gain a reputation of a highly-qualified specialist and a few international companies will probably offer you to continue building your career working for them. All a talented person needs is an opportunity; he’ll think out how to use it on his own.

4 Business-trips

You’ll often be offered to go on a business trip abroad. Especially if a company you work for has a few subdivisions abroad. Don’t neglect those opportunities: it is a good chance to travel and also to get new knowledge and skills, talk to people. Remember, the wider your horizons the more benefits you have.

5 An opportunity to move to the country you like

Old Level 08 - 2It often happens that when you’ve made a name for yourself as a highly-qualified specialist, you get an offer to move (to work) into your employer’s office. It’s very convenient. By that time you’ve probably been there on business trip and have a good knowledge of where you’re going. You already have friends and acquaintances there. You’ll get a good job and colleagues who now you well. Those are probably the best immigration conditions I know.

Demands of the global labor market

1 Your profession must meet them

Not all professions meet demands of global market. But many do. And this list grows constantly. I can keep naming them for a long time: support, development, research, design, almost anything to do with web and computers. If your profession appeared only 20-30 years ago, there is a very high probability that it can be easily globalized.

2 Price and quality

When a foreign company sees it can hire a specialist of higher quality and for a lower price in your country, it is hard to resist. You need to be either “better and cheaper” or “much cheaper”. Just “cheaper” will not satisfy the foreign company, because it risks a lot hiring specialists abroad.

3 English

In the 21-st century English is an international language. If you want to work on a global market and enjoy all of its benefits, but English is not your native language – learn it. The lower your English level the stronger should be other two advantages.

You have reached a new level

Level 8

Old Level 08 - 3

1 Elly, Explanation of collections

Old Level 08 - 4- Hey, Amigo. Today I want to tell you about collections. In Java, classes whose main purpose is to store a set of other elements are called collections/containers. The example of such a class, which you already know, is ArrayList. - In Java, the collections are divided into three main groups: Set, List, and Map. - So what’s the difference between them? - I’ll start with Set. Imagine a pile of shoes. It’s a Set. In the set, you can add an element, find or remove it. But the elements have no strict order there! - The explanation is too brief… - Now imagine the same pile of shoes, this time lined up along the wall. There is an order now. Every element has its number. For instance, you can find "pair number 7" by its number. This is a List. You can add the element in the beginning or in the middle of the list, or remove it, to do this all you need is its number. - Gotcha. What about Map? - Imagine the same shoes, but now on each pair there’s a label, e.g. «Nick», «Joe», or «Ann». This is a Map, it’s often called a «dictionary». Every element has its unique name you can access it by. The unique name of the element is also called the key. And a Map is a set of key-value pairs. The key doesn’t have to be a string. It can be of any type. The Map, which key type is Integer, is actually the List (with some differences). - It’s clear, but I’d like to see more examples. - Risha will give you examples, and I want to add a few more words. - All collections and containers store nothing when they are just created. But you can add elements to them after. They will change their size dynamically. - Oh, now it’s interesting. And how do you know how many elements are in the collection? - To do this, there’s the method size(). The collections have everything you need. I think in a couple of lessons you’ll see for yourself how handy these collections are. - I hope so.

1 Risha, List of all collections and interfaces

Old Level 08 - 5 - Hey, Amigo. - Hi-ya, Risha. - Lila told me that you wanted more examples of collections. I’ll give you a few. I want to show you a list of collections and interfaces: Old Level 08 - 6- Hum, so many. There are four Lists, three Sets and four Maps. - Yes, these are all various implementations of interfaces List, Set, and Map. - And what’s the difference between the implementations? - This is just what we are going to talk about today. Just wait a little. - Perhaps you already have some questions. - I know how to display list to the screen. And how to display Set and Map? - The elements of the List have a strict order, so they may be displayed simply by their numbers. Set and Map have no strict order of elements. Actually, the order of their elements may change when you add or remove any item. - Wow, that’s interesting! - Therefore, the special objects (iterators) were invented to work with collection elements. Using them you can run through all the elements of a collection, even if they have no numbers, only names (Map), or no names at all (Set). - Examples: Old Level 08 - 7- Wow! And what does all this mean? - In fact, it’s quite simple. First, we get a special iterator object from the collection. It has just two methods. 1 the method next() is to return the next element of the collection. 2 the method hasNext() is to check whether there are elements not returned by next() yet. - Yeah. It becomes clearer. Let me tell you how I understand it. - So, to get this magical iterator object, first, you need to call a method iterator() in a collection. - Then I get them one by one in the loop while there are unreturned items. I get the collection element by calling next() and check whether there are elements in an iterator using hasNext(). Am I right? - Yes, something like that. And now the most interesting thing. - In Java, there’s short notation of iterator usage. Similarly to while and for, another special operator «for each» was added. In code this operator is denoted by the same keyword for. - The for-each operator is only used with collections and containers. It hiddenly uses an iterator. - Let me show you a full and a short way to work with an iterator: Old Level 08 - 8- Please note: there are neither green nor red words in the right table. In fact, 3 lines are replaced by one: Old Level 08 - 9- It looks gorgeous. I like it more this way! - Let’s look at the same examples as above, only in short form: Old Level 08 - 10- It’s totally a different story! - I’m glad you like it.

3 Diego, Collection tasks

- Hey, Amigo. I want to give you some collection tasks:
Tasks
1 1. A plant HashSet
Create a HashSet collection of String type elements. Add to the collection 10 strings: watermelon, banana, cherry, pear, melon, blackberry, ginseng, strawberry, iris, and potato. Display to the screen the contents of the collection. Each entry should be on a new line. Watch how changed the order of added elements.
2 2. HashMap of 10 pairs
Create a collection HashMap<String, String>, place 10 pairs of strings into the collection: watermelon - berry, banana - grass, cherry - berry, pear - fruit, melon - vegetable, blackberry - berry, ginseng - root, strawberry - berry, iris - flower, potato - tuber.
Display to the screen the contents of the collection. Each entry should be on a new line.

Output example (only one string is shown):
potato - tuber
3 3. HashMap collection of cats
There is a class Cat, which has a field name (name, String).
Create a collection HashMap<String, Cat>.
Add 10 cats, using the cat name as a key.
Display to the screen the result. Each entry should be on a new line.
4 4. Display to the screen the list of keys
There is a collection HashMap<String, String>, it already has 10 different strings.
Display to the screen the list of keys. Each entry should be on a new line.
5 5. Display to the screen the list of values
There is a collection HashMap<String, String>, it already has 10 different strings.
Display to the screen the list of values. Each entry should be on a new line.
6 6. HashMap collection of Object
There is a collection HashMap<String, Object>, it already has 10 different object pairs.
Display to the screen the contents of the collection. Each entry should be on a new line.

Output example (only one string is shown):
Sim - 5

4 Kim, Introduction to the type Date

Old Level 08 - 11- Hey, Amigo. I’d like to tell you about an interesting type – Date. This type enables you to store a date and time, as well as to measure time intervals. - That looks promising. Go on. - Every Date object stores time information. It’s stored in a very interesting form - the number of milliseconds that have passed since January 1, 1970 GMT. - Wow! - Yeah. This number is so large that it doesn’t fit into int, you have to store it in long. But it’s very easy to calculate the difference between two dates: you only have to subtract one number from another to know the difference accurate to milliseconds. In future it will make your life easier, when you face time zones problems. - And the most interesting thing is that every Date object is initialized by its creation time. To check the current time, you just have to create an object. - And how to work with it? - Here are some examples: Old Level 08 - 12- The method getTime() returns the number of milliseconds stored in the object Date. - The method after() checks if the date, in which this method was called , comes after passed date. - Methods getHours(), getMinutes(), getSeconds() return the number of hours, minutes and seconds for the object in which they were called. - Moreover, in the last example, you see that it’s possible to manipulate the date/time stored in the object Date. We get the current time and date, and then set to zero the hours, minutes and seconds. Likewise we set the month to January, and the day of the month to 1. Now the object yearStartTime stores the date and time of January 1, 0 hours, 0 minutes, and 0 seconds. - Then we get the current date currentTime, again, and calculate the difference between the two dates in milliseconds. I’m talking about msTimeDistance. - Then divide msTimeDistance by the number of milliseconds in a day and get the total number of days passed since the beginning of the year to date! - Wow! That’s awesome!

5 Elly, ArrayList vs. LinkedList

- How about a little tuning up your mind? I hope it is not blown yet. - In the table of containers and collections above you have seen that the same interface can have multiple implementations. Now I’ll tell you why. And what’s the difference between the ArrayList and the LinkedList. - The thing is that the collection can be implemented in different ways and there’s no single correct implementation. In one approach, some operations are fast and the rest of them are slow. In the other approach, it’s the opposite. There is no single perfect solution. - Therefore, it was decided to make a few implementations of the same collection. Each implementation was optimized for a certain narrow range of operations. So there appeared different collections. Let’s consider an example of two classes - ArrayList and LinkedList. Old Level 08 - 13- The ArrayList is implemented internally as a regular array. Therefore, when an element is inserted into the middle, all the elements have to be shifted by one after it, and then the new element can be inserted into a vacant space. However, operations of getting and editing an element (get() and set()) are implemented very fast in the ArrayList. Because all they do is just access to the appropriate element of the inner array. - The LinkedList is implemented in a different way. It’s implemented as a linked list: a set of individual elements, each of which stores references to the next and previous elements. To insert an element into the middle of such list, method add() just changes references to its future neighbors. However, to get the element with number 130, method get() needs to run consistently through all the objects from 0 to 130. In other words, set and get here are very slow. Look at the table below: Old Level 08 - 14- Yeah. It’s getting clearer now. Are there any criteria or rules, which collection is best? - Well, to simplify, here is the following rule: if you’re going to insert (or remove) many elements in the middle of the collection, then you’d better use a LinkedList. Otherwise, use an ArrayList. - I will explain you the internal structure of these lists at the senior levels. So far we’ll learn how to use them.

6 Diego, Task: measure the performance of both lists

- It’s you. I began to get bored. Where have you been? Here are the tasks. - Are they interesting? - Why, sure! Very interesting:
Very interesting tasks
1 1. Create two lists LinkedList & ArrayList.
Create two lists: LinkedList and ArrayList.
2 2. Do 10 thousand insertions and deletions
Do 10 thousand of each insertions, deletions, calls of get() and set() methods for the arrayList and linkedList.
3 3. Measure how long it takes to do ten thousand insertions for each list
Measure how long it takes to do ten thousand insertions for each list.
The method getTimeMsOfInsert() should return the time of its execution in milliseconds.
4 4. Measure time needed to do ten thousand calls of get for each list
Measure time needed to do ten thousand calls of get() for each list
The method getTimeMsOfGet() should return the time of its execution in milliseconds.
5 5. Four methods
Implement 4 methods. The methods should return a list best suited to perform specified operations (to cope fast with a large number of operations). No measurement needed.

7 Elly: Set and Map, what can be done with them

- Aren’t you tired yet? No, then let’s continue. I’d like to explain you what Set and Map are. And what operations they have. - Set is a bunch of non-enumerated objects. The main feature of Set is that it has unique objects only, that is, they’re all different. That’s what you can do with it: Old Level 08 - 15- Is that all? - Actually, yes. You can also determine the number of elements using the method size(). - What about Map? - Map is a pair set. It’s the very same set, not of single elements, but of key-value pairs. The only restriction is that the first object in a pair, which is called the key, is to be unique. Map cannot contain two pairs with the same keys. - That’s what we can do with Map: Old Level 08 - 16- This is far more interesting than set. - Yes, though Map is not as popular as the list, is used for many tasks.

8 Diego, Set & Map tasks

- I hope you’ve already learned what Set and Map are? Here are some Set and Map tasks.
Collection tasks
1 1. 20 words beginning with «L»
Create a set of strings (Set<String>), place into it 20 words beginning with «L».
2 2. Remove all the numbers greater than 10
Create a set of numbers (Set<Integer>), place into it 20 different numbers.
Remove from the set all the numbers greater than 10.
3 3. Identical first and last names
Create a dictionary (Map<String, String>) and add ten entries according to the model «last name» - «first name». Check how many people have the same first or last name as the name specified.
4 4. Remove all the people born in the summer
Create a dictionary (Map<String, Date>) and add ten entries according to the model «last mane» - «birth date». Remove from the map all the people born in the summer.
5 5. Remove people having the same first name
Create a dictionary (Map<String, String>) and add ten entries according to the model «last name» - «first name». Remove people that have the same first name.

9 Professor, Lecture on collections

Old Level 08 - 17- Haw-haw. We finally got to the collections. I still have a wonderful lecture from the time I was a student. It’s a little bit dusty, of course, but fundamentally great. Here are my notes: Java Collections (Oracle Documentation) Collections in Java (Java T point) Java Collections Framework (tutorials point) Java Collections Tutorial

10 Julio

- Good Lord! You’re overworked again! Didn’t I tell you not to work so much? Let me play something to help you relax:

11 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. Set of cats
1. Create a public static class Cat within the class Solution.
2. Implement the method createCats(), which should create a Set of cats and add three cats to it.
3. In the main method, remove a cat from the Set cats.
4. Implement the method printCats(), which should display to the screen all the cats that remain in the set. Every cat should be on a new line.
2 2. Set of all animals
1. Create public static classes Cat and Dog within the class Solution.
2. Implement the method createCats(), which should return a set of 4 cats.
3. Implement the method createDogs(), which should return a set of 3 dogs.
4. Implement the method join(), which should return the combined set of all animals, both cats and dogs.
5. Implement the method removeCats(), which should remove from the set pets all the cats present in the set cats.
6. Implement the method printPets(), which should display to the screen all the animals present in it. Each animal should be on a new line.
3 3. People with the same first names and/or last names
1. Create a dictionary (Map<String, String>) and add 10 persons according to the model «last name» - «first name».
2. Among these 10 persons, let there be people with the same first names.
3. Among these 10 persons, let there be people with the same last names.
4. Display to the screen contents of the Map.
4 4. The minimum of N numbers
1. Read from the keyboard number N.
2. Read from the keyboard N integers and fill a list with them using a method getIntegerList().
3. Find the minimum number among the elements of the list using a method getMinimum().
5 5. Stop Look Listen. Now capitalized
Write a program that should read from the keyboard a string.
The program should replace the first letters of all words in the text with the uppercase.
Display to the screen the result.

Example input:
stop look listen
Example output:
Stop Look Listen
6 6. The whole family is together
1. Create a class Human with the fields: String name, boolean sex, int age, ArrayList<Human> children.
2. Create 9 objects and fill them in such a way as to obtain two grandfathers, two grandmothers, a father, a mother, and three children. 3. Display to the screen all the Human objects.
7 7. Move one modifier static
Move one static modifier so the code compiles.
8 8. Five largest numbers
Create an array of 20 numbers. Fill it with numbers that are read from keyboard. Display to the screen five largest numbers.
9 9. Working with date
1. Implement the method isDateOdd(String date) so that it returns true, if the number of days from the beginning of the year is odd, otherwise it returns false.
2. String date is passed in the format MAY 1 2013

JANUARY 1 2000 → true
JANUARY 2 2020 → false
- Those tasks were for greens. I added bonus tasks of higher complexity. For top guns only.
Bonus tasks
1 1. Month number.
The program should read from the keyboard the name of the month and display to the screen its number in following way: «May is 5 month»
2 2. Add new functionality to the program.
Old Task: The program determines which family (its last name) lives in a house with the specified number.
New task: The program should work with the cities and not with house numbers.

Example input:
Washington
the Smiths
New York
the Browns
London
the Johnsons

London

Example output:
the Johnsons
3 3. Learning and practicing algorithm.
Task: The program should read from the keyboard 20 words and display them in alphabetical order.
Comments
  • Popular
  • New
  • Old
You must be signed in to leave a comment
This page doesn't have any comments yet