In this video, we'll talk about specifics of Java. We'll start with Input/Output. The most convenient way to rate values is by using Scanner class. But the issue is, it's very slow. It can only be used for small inputs like 10,000 integers or less and there is no any other alternative with the same functionality. So, we need to construct it. Which does create input fast is the BufferedReader class. But, it only reads whole lines without splitting on [inaudible] numbers or words. So, we need to parse the lines aligned by BufferedReader to an instance of StringTokenizer which will split them into tokens. After that, we could easily parse integers or what else we need with functions like Integer.parseInt or similar ones. And so, all that together makes a fast alternative for the Scanner. It makes sense to put everything in one class and define methods with Scanner-like names like nextInt or nextDouble. It's also useful to write it once and then put it in your template code, so as not to write it every time from scratch. With output, it's simpler as the standard PrintWriter class has all necessary functions and is fast enough. Next, Java has a large variety of containers, data structures. But, they always store objects and they would often, I would like to store primitives like Ints. Of course, we could use primitive wrappers like Capital Integer. But, as the object, they take much more space than just Ints. For example, Capital Integer takes 16 bytes while Int just four bytes. So, when using Collections with primitives, we get substantial object overheads in terms of space and time. And thus for example, ArrayList of integers is much worse than just an array of Ints. And so, you should use Arrays when you can, when you work in script with primitives. Also, Collections come in two kinds, synchronised and unsynchronised. For example, Vector and ArrayList, they do basically the same, only the first one is synchronised and the second not synchronised. The difference is, synchronised Collections are designed for more detailed performance. And unsynchronised, on the other hand, are optimized for single threads. And so, on competitions as it's always single threads then we should use unsynchronised Collections like ArrayList. Next, about Strings, the basic string class is fine enough. The only issue is, its instances are immutable. It means that each time an object changes, a new copy of it is created. And particularly, if we append character by character to a string each time, there is a new object and so, linear number of appends leads to a chaotic time. In fact, there is another class just for that. It's called StringBuilder and it has append methods which just appends a single character. But, it does it in constant time. Of course, you could also use like other list of characters, but the StringBuilder, there is no object overhead. Finally, some other remarks you need to keep in mind when estimating memory of custom classes that an object of custom class takes space, takes more space than just the sum of its fields, at least by eight bytes. So, you need to be careful with memory. Another thing, there are in fact two different sorting algorithms in Java. One is Collections.sort and the second is Arrays.sort. They are different. Collections.sort is a merge sort and so it works always when you go often against time and it's stable. In contrast, Arrays.sort is quick sort and so, it's not stable but what's worse, there are special cases where it's going to take time. So, it makes sense to randomly shuffle an array before doing Arrays.sort, just in case. Next, as objects are always assigned by reference, do not forget to clone them when needed. Because, if you have several different pointers to assign an object, then changing one, changes also the others. And clone it to various separate box when you don't expect something to change and it changes. So, watch for it. And, that's all for Java.