This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace mynamespace; | |
| class ArrayRecurseComparator | |
| { | |
| public function compareArraysRecursively($actual, $expected) | |
| { | |
| $trigger = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * 1. World War I: 28 07 1914 | |
| * 28+07+19+14= 68 | |
| * 2. World War II: 01 09 1939 | |
| * 01+09+19+39= 68 | |
| * 3. World War III(russia invasion in of Ukraine): 24 02 2022 | |
| * 24+02+20+22= 68 | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #arg1 integer | |
| #arg2 integer | |
| gcd(){ | |
| local a=$1 | |
| local b=$2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 2)Пояснити що таке Comparator i Comparable: | |
| Comparable - This interface has one method compareTo. Class whose objects to be sorted must implement this Comparable interface. In this case there is one form or way of sorting, e.g. We can sort players by age, so if we want to sort them by ranking or by name, in this case we have to change our Player class and change compareTo method to do that. | |
| Comparator - This interface has two methods equals and compare. Class whose objects to be sorted do not need to implement this Comparator interface. Some third class can implement this interface to sort. In this case there are multiple forms of sorting, we can write different sorting based on different attributes of objects to be sorted, e.g. We can sort players by age, by ranking, and by namewithout change our Player class, to do that we use other class for Age Comparison and other class for Ranking Comparison and other class for Name Comparison. | |
| 3) Чому в PriorityQueue MAX capacity - MAX_INTEGER- 8? - Some VMs rese |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. https://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html | |
| 2. https://stackoverflow.com/questions/19782314/why-cant-arrays-be-resized | |
| When you create an array, using int[] array = new int[5] for instance, the computer reserves five consecutive spaces in | |
| memory for the data to be contained in that array. However, the spaces in memory after that can be used right away to | |
| store other information. If the array were to be resized later on, that other information would have to be moved somewhere | |
| else in order for the array to get bigger. That's a lot of shuffling that we don't want to deal with, so computer architects | |
| disallow array resizing to make things simpler. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| public class HomeTaskThree { | |
| public static void main(String[] args) { | |
| //Task - 1,2 - I have read about it. | |
| //Task - 3. DESC sorting of arr of integers | |
| Integer [] arr0 = new Integer[]{2, 3, 1, 7, 11}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.javarush.task.task15.task1525; | |
| import java.io.*; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| /* | |
| Файл в статическом блоке | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Solution { | |
| public static void main(String[] args) { | |
| Singleton s = Singleton.getInstance(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void main(String[] args) throws IOException | |
| { | |
| InputStream inStream = new FileInputStream("c:/source.txt"); | |
| OutputStream outStream = new FileOutputStream("c:/result.txt"); | |
| while (inStream.available() > 0) | |
| { | |
| int data = inStream.read(); //читаем один байт из потока для чтения | |
| outStream.write(data); //записываем прочитанный байт в другой поток. | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.javarush.task.task11.task1123; | |
| public class Solution { | |
| public static void main(String[] args) throws Exception { | |
| int[] data = new int[]{1, 2, 3, 5, -2, -8, 0, 77, 5, 5}; | |
| Pair<Integer, Integer> result = getMinimumAndMaximum(data); | |
| System.out.println("Minimum is " + result.x); | |
| System.out.println("Maximum is " + result.y); |
NewerOlder