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.iryna.datastructures.map; | |
| import java.util.Iterator; | |
| public interface Map<K, V> extends Iterable { | |
| V put(K key, V value); | |
| V get(K key); | |
| boolean containsKey(K key); |
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.ohapon.datastructures.queue; | |
| import java.util.*; | |
| public class Test { | |
| private static final Comparator<Person> PERSON_ID_DESC_COMPARATOR = new Comparator<Person>() { | |
| @Override | |
| public int compare(Person o1, Person o2) { | |
| return o2.id - o1.id; |
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: Написать программу FileAnalyzer, которая в консоли принимает 2 параметра: | |
| 1) путь к файлу | |
| 2) слово | |
| Usage: | |
| java FileAnalyzer C:/test/story.txt duck | |
| Выводит: | |
| 1) Кол-во вхождений искомого слова в файле | |
| 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
| package com.ohapon.datastructures.list; | |
| import org.junit.Test; | |
| import static org.junit.Assert.*; | |
| public abstract class AbstractListTest { | |
| List list = getList(); | |
| abstract List getList(); |
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 interface List { | |
| // add value to the end of the list | |
| void add(Object value); | |
| // [A, B, C, null, null ] size = 3 | |
| // add (D, [0,1,2,3]) | |
| // we can add value by index between [0, size] | |
| // otherwise throw new IndexOutOfBoundsException | |
| void add(Object value, int index); |
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
| https://docs.google.com/presentation/d/1EFemyFDcu4iYAhSEzzdv71kTT8krlzPrxL1HfLz0n_g/edit?usp=sharing | |
| https://www.youtube.com/watch?v=MniNZsyjH9E |
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.luxoft.reflection; | |
| import java.lang.annotation.ElementType; | |
| import java.lang.annotation.Retention; | |
| import java.lang.annotation.RetentionPolicy; | |
| import java.lang.annotation.Target; | |
| import java.lang.reflect.Field; | |
| @Retention(RetentionPolicy.RUNTIME) |
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
| Reflection: | |
| Метод принимает класс и возвращает созданный объект этого класса | |
| Метод принимает object и вызывает у него все методы без параметров | |
| Метод принимает object и выводит на экран все сигнатуры методов в который есть final | |
| Метод принимает Class и выводит все не публичные методы этого класса | |
| Метод принимает Class и выводит всех предков класса и все интерфейсы которое класс имплементирует | |
| Метод принимает объект и меняет всего его приватные поля на их нулевые значение (null, 0, false etc)+ | |
| Annotations: | |
| - Принимает объект и вызывает методы проанотированные аннотацией @Run (аннотация Ваша, написать самим) |
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 java007d05; | |
| import java.util.Iterator; | |
| import java.util.Objects; | |
| import java.util.StringJoiner; | |
| // is - a | |
| public class LinkedList implements List, Iterable { | |
| private Node head; |
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 junit.extensions; | |
| import junit.extensions.ActiveTestSuite; | |
| import java.util.ArrayList; | |
| import java.util.Iterator; | |
| import static org.junit.Assert.*; | |
| public class EvilTest { |