1. trainer
    1. Ihar Blinou
  2. schedule
    1. 9:00 - 16:00
    2. dinner
      1. 14:00 - 15:00
  3. contents
    1. main concepts
    2. exceptions
    3. jdbc
    4. xml
    5. collections
    6. multithreading
    7. networking
  4. books
    1. java code conventions
    2. core java
      1. horstman
      2. полный справочник
    3. code complete
    4. java philosophy
      1. eckel
    5. java - промышленное программирование
    6. refactoring to patterns
  5. resources
    1. http://tutorials.jenkov.com
    2. http://java2s.com
  6. features
    1. no functions, only methods
      1. all functions are inline
    2. everything is a class
    3. every language construct in a separate file
    4. there should be no two public classes in one file
    5. static method cannot be virtual
    6. all classes are in package
      1. there is default package
    7. every object is passed via reference
    8. == vs equals
    9. oop principle obtrusion
      1. serialization/deserialization
    10. deep cloning
      1. horstman
    11. case sensitive
    12. str to num
      1. Integer.parseInt
      2. Integer.valueOf
      3. Integer.decode
      4. new Integer
  7. questions
    1. @override and other annotations
    2. code inspections
      1. jlint
      2. pmd
      3. checkstyle
    3. copying objects
    4. why do we need static import?
    5. casting/conversion
      1. classes
      2. interfaces
      3. arrays
    6. constructors are not inherited
      1. ??
    7. are arrays serializable?
    8. instanceof vs getClass
  8. code conventions
    1. methods
    2. classes
    3. constants
    4. packages
  9. design patterns
    1. GOF
      1. types
        1. creational
          1. singleton
          2. assumes only one (or limited) instance(s) of specific class
          3. factory
          4. factory creates objects of different subclasses using similar approach
          5. abstract factory
          6. factory method
          7. builder
          8. builder creates one large object
          9. prototype
        2. structural
          1. composite
          2. used for hierarchical data representation (fs tree, xml, categories, syntax parser, matryoshka doll etc)
          3. features
          4. recursive composition
          5. allows treat both individual objects and their clusters uniformly
          6. examples
          7. fs tree
          8. xml
          9. categories
          10. syntax parser
          11. AST
          12. matryoshka doll
          13. hierarchies
          14. church
          15. military
          16. aristocratic
          17. administrative
          18. genres
          19. art
          20. music
          21. compexity classes
          22. decorator
          23. wrapper is the synonym of decorator
          24. facade
          25. provides interface for the more complex architecture
          26. flyweight
          27. proxy
          28. bridge
          29. features
          30. run-time binding implementation
          31. hierarchies are being implemented independently
          32. decoupling abstraction from implementation
          33. example
          34. different implementations for different platforms
          35. adapter
          36. matches interfaces of different classes
          37. features
          38. legacy classes have replacements
          39. decorator provides enhanced interface
          40. facade defines new interface while adapter reuses the old one
        3. behavioral
          1. command
          2. observer/listener
          3. chain of responsibility
          4. iterator
          5. mediator
          6. memento
          7. imitates ctrl+z behavior
          8. often used in a tandem with a command pattern
          9. state
          10. strategy
          11. template method
          12. visitor
    2. GRASP
      1. knowledge classes
      2. action classes
      3. patterns
        1. expert
        2. high cohesion
        3. glaukap ??
    3. examples
      1. http://fluffycat.com
  10. language
    1. errors handling
      1. exceptions
        1. try-catch-finally
          1. finally
          2. used for
          3. db connection close
          4. close files
          5. release other allocated resources
        2. throw
        3. throws
        4. types
          1. checked
          2. throws
          3. Exception
          4. unchecked
          5. RuntimeException
        5. multiple catch blocks
          1. two catches cannot handle exception
        6. catch(Exception e)
          1. deprecated!
        7. redefine constructor in order to be able passing error message
        8. all exceptions implement interface Throwable
        9. classes
          1. IOException
          2. NullPointerException
          3. ArithmeticException
          4. CloneNotSupportedException
        10. inheritance
          1. subclass methods should throw subexceptions which overridden method throws
          2. narrowing approach
          3. subclass constructor should throw all exceptions (or its parent classes) parent constructor throws
          4. widening approach
      2. errors
        1. OutOfMemoryError
        2. StackOverflowError
        3. program is allowed to terminate
      3. assertions
        1. assert <condition>:<expression>;
    2. JavaBeans
      1. public contstructor
        1. for possibility of creation via reflection
      2. implements Serializable
      3. private fields
      4. setters/getters
      5. concept
        1. object as a single information domain
    3. types
      1. base types
        1. boolean
          1. Boolean
          2. booleanValue
          3. parseBoolean
        2. byte
          1. Byte
          2. byteValue
          3. parseByte
        3. char
          1. Character
          2. charValue
          3. ----
        4. short
          1. Short
          2. shortValue
          3. parseShort
        5. int
          1. Integer
          2. intValue
          3. parseInt
        6. long
          1. Long
          2. longValue
          3. parseLong
        7. float
          1. Float
          2. floatValue
          3. parseFloat
        8. double
          1. Double
          2. doubleValue
          3. parseDouble
        9. valueOf
      2. primitive
        1. byte
          1. 1
        2. short
          1. 2
        3. int
          1. 4
        4. long
          1. 8
        5. float
          1. 4
        6. double
          1. default
          2. 8
        7. char
          1. 2
        8. bool
        9. arithmetic promotion (implicit)
          1. long
          2. char
          3. int
          4. short
          5. byte
          6. float
          7. double
    4. literals
      1. number
        1. int
          1. 10
          2. 012
          3. 0xA
        2. float/double
          1. 1.0001
          2. 5.3e-3
          3. 6.89e-8f
      2. chars
        1. \u0004
        2. 'a'
        3. escape sequence
          1. \n
          2. \r
          3. \t
          4. \b
          5. \f
          6. \'
          7. \"
          8. \\
      3. null
      4. boolean
        1. true
        2. false
      5. NaN
    5. variables
      1. types
        1. local
        2. static
        3. instance
    6. comments
      1. javadoc
        1. @
          1. author
          2. version
          3. exception
          4. param
          5. return
          6. deprecated
          7. since
          8. throws
          9. see
          10. ...
      2. one line
        1. //
      3. multiline
        1. /* */
    7. operators
      1. relative
        1. !=
        2. <=
        3. >=
        4. >
      2. other
        1. ==
          1. &
          2. ^
          3. *
          4. |
          5. &&
          6. ||
          7. ? :
          8. =
      3. arithmetic
        1. +
        2. ++
        3. -
        4. --
        5. *
        6. /
        7. %
          1. remainder
      4. logical
      5. bitwise
      6. assignment
      7. flow
        1. switch/case
          1. does not accept long ??
        2. for
        3. while
        4. do
        5. continue
        6. break
      8. advanced
        1. []
        2. ? :
        3. .
        4. ()
          1. casting
          2. params list
        5. new
        6. instanceof
          1. returns true for
          2. class
          3. or its subclass
          4. 'a instanceof Object' always returns true
          5. except 'null instanceof Object';
    8. oop
      1. constructors
        1. default constructor is used when explicit constructor is absent
        2. overloading
        3. not always default constructor is reasonable
        4. constructor is
          1. the class method without return value
        5. are not inherited
      2. inheritance
        1. all methods and fields are inherited to subclass
        2. logical blocks are not inherited
        3. default class is being Object inherited
        4. fields are not overridden even though they are being inherited
          1. there might be id field in both parent and subclass
      3. incapsulation
        1. access modifiers
          1. private
          2. protected
          3. default (private-package)
          4. public
      4. polymorphism
        1. types
          1. static
          2. templates
          3. template methods
          4. overloading
          5. generics
          6. ?
          7. dynamic
          8. late binding
          9. overriding
          10. method visibility should be widened, not narrowed
        2. ability of change reference depending on the passed object type
        3. polymorphic substitution
          1. static + dynamic = combined polymorphism
          2. sublass reference cannot be initialized with superclass object
      5. relationships
        1. is-a
        2. has-a
      6. modifiers
        1. abstract
        2. final
        3. static
        4. transient
        5. native
        6. synchronized
        7. volatile
        8. private
        9. public
        10. protected
      7. classes
        1. abstract
        2. inner
          1. 1 to 1 classes relationship
          2. used for
          3. unique concept existing only in the scope of the outer class
          4. compound data types
          5. Enum declarations
          6. outer class cannot see fields and methods of inner class if there is no instance
          7. inner class sees all, even private
          8. access to outer class instance
          9. Outer.this.field
          10. subclass of inner class loses access to the outer class
          11. though subclasses of inner and outer keep accessibility rules
        3. nested
          1. static inner class
          2. can be created without instantiation of outer class
          3. static keyword before inner class definition describes instantiation approach. it tells nothing about fields and methods
          4. new Outer.Inner()
          5. no instance of outer class required
          6. inner classes of interfaces are static by default
          7. can imitate methods implementation inside the interface
        4. anonymous
          1. example
          2. AnonClass anon = new AnonClass { ... }
          3. inherited from the class where it is defined
          4. often used in enums
          5. in case of abstract method definition in enum it is required to override it with anon class in each enum value
          6. it is not allowed to inherit from enum
      8. interfaces
        1. names
          1. -able
          2. Serializable
          3. -or
          4. Iterator
        2. should represent complex actions
        3. can have details of implementation
        4. can inerit from each other
          1. extends keyword
        5. interfaces parametrization
        6. vs abstract classes
          1. it is useful to parametrize interface with the abstract class
          2. interface Interface<T extends AbstractClass>
          3. common
          4. cannot create objects
          5. unimplemented methods
          6. difference
          7. class has
          8. fields
          9. methods
          10. constructor
          11. abstract
          12. reasonable when there are
          13. common fields
          14. common methods implementation
          15. single inheritance
          16. can have default implementation
          17. interface
          18. just a list of methods
          19. multiple inheritance
      9. super
        1. super(a, b, c)
        2. super.method()
        3. each constructor of inherited class has implicit super() call without params
      10. this
        1. this(a, b, c)
          1. chain constructor
        2. this.method()
    9. import
      1. static
        1. import static java.util.Math.*
      2. java.util.* is imported by default
    10. types
      1. numeric
        1. Number
          1. Byte
          2. Short
          3. Integer
          4. Long
          5. BigInteger
          6. BigDecimal
          7. Float
          8. Double
      2. String
        1. immutable
        2. if literal is the same, reference also the same
          1. String s1 = "Java"
          2. String s2 = "Java"
          3. String s3 = "Ja" + "va"
        3. methods
          1. concat
          2. individual chars
          3. charAt
          4. comparison
          5. compareTo
          6. compareToIgnoreCase
          7. equals
          8. equalsIgnoreCase
          9. contentsEqualsTo
          10. substring search
          11. startsWith
          12. endsWith
          13. indexOf
          14. lastIndexOf
          15. substring
          16. extract substring
          17. uppercased string
          18. toUpperCase
          19. lowercase string
          20. toLowerCase
          21. length
          22. replace
          23. trim
          24. toString
          25. valueOf
          26. intern
          27. String s1 = "Java"
          28. String s2 = new String("Java")
          29. s1 == s2 -> false
          30. s2 = s1.intern()
          31. s1 == s2 -> true
          32. isEmpty
          33. added in java 6
          34. format
          35. split
        4. buffers
          1. StringBuffer
          2. modifiable strings
          3. append
          4. insert
          5. reverse
          6. setCharAt
          7. deleteCharAt
          8. setLength
          9. toString
          10. StringBuilder
          11. unsynchronized StringBuffer
          12. hashCode and equals are not overridden for both classes
        5. Locale class
          1. getCountry
          2. getDisplayCountry
          3. getLanguage
          4. getDisplayLanguage
          5. ...
        6. regexes
          1. Pattern class
          2. compile
          3. matches
          4. matcher
          5. split
          6. toString
        7. formatting
          1. numbers
          2. dates
          3. currency
          4. Formatter class
          5. close
          6. flush
          7. format
          8. toString
          9. %[<argumentIndex>$][<flags>][<width>][.<precision>] <type>
          10. types
          11. %b
          12. Boolean
          13. %c
          14. Character
          15. %d
          16. Decimal
          17. %f
          18. Floating point
          19. %s
          20. String
        8. parsing
          1. Scanner class
        9. all related classes are final
      3. arrays
        1. cannot convert into each other
        2. arrays array
          1. references array
        3. definition
          1. {}
      4. enums
      5. generics
        1. ?
          1. anonymous type
        2. T
          1. type
        3. can use 'extends' keyword
        4. can not
          1. generic constructor can not be instantiated
          2. be used in static methods
    11. logical blocks
      1. types
        1. default
          1. run on class initialization
        2. static
          1. run on class loading
      2. run only once
    12. methods
      1. variable params
        1. method(String s, int ... k)
        2. method(String ... s)
        3. method(Object ... o)
        4. method(int ... k)
          1. method(1, 2, 3, 4)
        5. method(String[] ... arr)
        6. should be at the end
        7. works with both params list and arrays
    13. autoboxing/unboxing
      1. Integer num = 170
        1. object creation + boxing
      2. Integer k = ++num
        1. unboxing + operation + object creation + boxing
      3. int i = k
        1. unboxing
      4. Integer i = null
      5. int j = i
      6. dynamic comparison
        1. unboxing, comparison, boxing
      7. Float f = new Float("7")
    14. serialization
      1. implements Serializable
      2. requires serialVersionUID
      3. transient
        1. cannot be serialized
          1. as well as static fields
    15. collections
      1. hierarchy
        1. Map
          1. SortedMap
          2. AbstractMap
          3. TreeMap
          4. HashMap
          5. LinkedHashMap
          6. EnumMap
          7. WeekHashMap
          8. Subtopic 1
          9. IdentityHashMap
          10. allow duplicated keys
          11. System.identityHashCode()
          12. Hashtable
        2. Collection
          1. List
          2. AbstractCollection
          3. AbstractList
          4. ArrayList
          5. AbstractSequenceList
          6. LinkedList
          7. Vector
          8. Stack
          9. AbstractQueue
          10. PriorityQueue
          11. ArrayDeque
          12. AbstractSet
          13. TreeSet
          14. HashSet
          15. LinkedHashSet
          16. EnumSet
          17. Set
          18. NavigableSet
          19. SortedSet
          20. Queue
          21. Deque
          22. ArrayDeque
      2. thread-safety
        1. java 1
          1. all thread-safety
        2. java 2
          1. emerged non thread-safety
      3. methods
        1. Collection
          1. add
          2. addAll
          3. clear
          4. equals
          5. isEmpty
          6. iterator
          7. remove
          8. size
          9. Queue
          10. element
          11. remove
          12. offer
          13. peek
          14. poll
        2. List
          1. indexOf
          2. add
          3. addAll
          4. get
          5. remove
          6. set
          7. subList
          8. LinkedList
          9. addFirst
          10. addLast
          11. getFirst
          12. getLast
          13. removeFirst
          14. removeLast
          15. removeFirstOccurence
          16. removeLastOccurence
        3. Comparator
          1. compare
          2. sort
        4. Comparable
          1. compareTo
        5. TreeSet
          1. first
          2. last
          3. subSet
          4. tailSet
          5. headSet
          6. comparator
        6. EnumSet
          1. noneOf
          2. of
          3. complementOf
          4. range
        7. Map
          1. containsKey
          2. containsValue
          3. entrySet
          4. keySet
          5. get
          6. put
          7. putAll
          8. remove
          9. values
        8. Map.Entry
          1. getKey
          2. getValue
          3. setValue
      4. auxillary interfaces
        1. Iterator<T>
          1. reference to the next element
          2. methods
          3. hasNext
          4. next
          5. remove
        2. Comparator<T>
        3. Map.Entry
        4. Enumeration<T>
          1. methods
          2. elements
          3. keys
      5. auxillary classes
        1. Collections
          1. static class with static methods for actions with collections
          2. methods
          3. checkedCollection
          4. addAll
          5. copy
          6. disjoint
          7. emptyList
          8. fill
          9. frequency
          10. max
          11. min
          12. nCopies
          13. replaceAll
          14. reverse
          15. rotate
          16. shuffle
          17. singletonMap
          18. sort
          19. swap
        2. Arrays
          1. class for manipulation with arrays
          2. methods
          3. fill
          4. sort
          5. copyOf
          6. copyOfRange
          7. asList
      6. foreach
        1. is applicable on classes implementing Iterable interface
      7. TreeSet cannot be parameterized with StringBuilder or StringBuffer
        1. because those classes do not have compareTo implemented
      8. how to make java 1.4 collection type-safe?
        1. checkedCollection method
    16. multithreading
      1. application has at least one thread: main
        1. it waits until all spawned thread will be terminated
      2. class Thread
        1. methods
          1. run
        2. throws InterruptedException
      3. interface Runnable
        1. methods
          1. run
          2. start
      4. thread
        1. states
          1. new
          2. ready/runnable
          3. running
          4. non-runnable
          5. sleeping
          6. time waiting
          7. blocked
          8. state becomes active on synchronization
          9. waiting
          10. wait
          11. is called on non-runnable thread
          12. stops thread
          13. releases object block
          14. object becomes available
          15. notify
          16. makes thread ready
          17. notifyAll
          18. all waiting threads are notified to be ready
          19. it is not recommended to kill/terminate/interrupt thread from non-runnable state
          20. dead/terminated
          21. class State
        2. priorities
          1. MIN
          2. MAX
          3. NORM
      5. groups
        1. ThreadGroup class
      6. control
        1. yield
        2. join
          1. ?
        3. close
      7. daemons
        1. isDaemon
        2. setDaemon
      8. synchronization
        1. thread-safety of
          1. file
          2. object
          3. thread
        2. it is not required for writing/reading
          1. except 64bit platform
      9. semaphors
        1. restrict the number of threads than can access some (physical or logical) resource
      10. core
        1. java.util.concurrent.*
          1. ConcurrentHashMap
          2. CopyOnWriteArrayList
          3. Executor
          4. AtomicInteger
          5. AtomicLong
          6. AtomicReference
          7. SynchronizedInt
          8. Semaphore
          9. CyclicBarrier
          10. Exchanger
    17. core
      1. IO
        1. java.io.File class
        2. streams
          1. low-level
          2. FileInputStream
          3. FileOutputStream
          4. ObjectInputStream
          5. ObjectOutputStream
          6. high-level
          7. DataInputStream
          8. DataOutputStream
        3. readers
          1. low-level
          2. FileReader
          3. high-level
          4. BufferedReader
          5. file
          6. socket
          7. readline
        4. writers
          1. low-level
          2. FileWriter
          3. high-level
          4. BufferedWriter
          5. PrintWriter
      2. Random
        1. java.util.Random
      3. Object
        1. clone
          1. class should implement Cloneable interface
          2. if interface is not implemented, then CloneNotSupportedException will be raised
          3. approach
          4. deep
          5. example is in the book by Horstman
          6. shallow
          7. super.clone()
          8. immutable objects are cloned automatically
        2. hashCode
          1. implementation should try to map object and unique hash code
        3. equals
          1. equals assumes that two equal objects have the same hash codes
          2. Effective Java describes how to violate equivalence criteria
          3. consists of
          4. null check
          5. objects classes check
          6. object casting
          7. object properties null check
          8. object properties comparison
        4. toString
        5. getClass
          1. part of the the reflection mechanizm
        6. finalize
          1. Effective Java describes the way how to halt the system with finalize overriding
        7. threading
          1. notify
          2. notifyAll
          3. wait
      4. ResourceBundle
      5. Properties
      6. console
        1. System.console()
        2. console.readPassword()
      7. Scanner
      8. zip
      9. jar
  11. jdbc
    1. concepts
      1. result sets
      2. queries
        1. run on the statement instance
        2. CRUD
          1. create
          2. st.executeUpdate("INSERT employee VALUES(" + 13 + "," + "'Aman'" + ")");
          3. retrieve
          4. udpate
          5. delete
        3. example
      3. statements
        1. example
          1. Statement st = connection.createStatement()
        2. types
          1. prepared
          2. PreparedStatement
          3. executeBatch
          4. callable
          5. CallableStatement
          6. for stored procedures
      4. drivers
        1. driver should be loaded into memory
          1. Class.forName(driverName)
          2. new com.mysql.jdbc.Driver()
      5. metadata
        1. used to work with table and db structure
        2. interfaces
          1. ResultSetMetaData
          2. methods
          3. getColumnCount
          4. getColumnName
          5. getColumnType
          6. DatabaseMetaData
          7. methods
          8. getDatabaseProductName
          9. getDatabaseProductVersion
          10. getDriverName
          11. getUserName
          12. getURL
          13. getTables
        3. example
          1. ResultSetMetaData md = resultSet.getMetaData()
          2. DatabaseMetaData md = connection.getMetaData()
      6. connections
        1. example
          1. Connection.getConnection("jdbc:mysql://localhost:3306/mydb")
        2. uses specific connection syntax
          1. jdbc:[dbtype]://[host]:[port]/[dbname]
        3. surely should be closed
        4. connection creation is really expensive
        5. pools
          1. in connection pools connections are placed into the list (pool) in order to store expensive connections and allow users to use them
      7. DAO
        1. Data Access Object pattern
  12. log4j
    1. appender
      1. console
      2. files
      3. gui
      4. jms
      5. sockets
      6. event loggers
      7. syslog
    2. levels
      1. TRACE
      2. DEBUG
      3. INFO
      4. WARN
      5. ERROR
      6. FATAL
    3. rotation
      1. every N hours/days/... new file is being created
    4. layouts
    5. custom filters
  13. jUnit
    1. test cases
    2. fixtures
      1. @Before
      2. @After
      3. @Test
      4. @BeforeClass
    3. suites
    4. assertions
    5. exceptions handling
      1. @Test(expected=Exception.class)
    6. parameterized test
    7. timeout test
  14. networking
    1. classes
      1. Socket
        1. example
          1. Socket sock = new Socket(host, port)
          2. Socket sock = new ServerSocket(port)
      2. InetAddress
      3. DatagramSocket
    2. auxillary classes usage
      1. BufferedReader
      2. InputStreamReader
      3. PrintStream
  15. tasks
    1. lesson 1
      1. chapter 3,4
      2. implementation of factory and/or command
    2. lesson 3
      1. composite + builder
      2. bridge
      3. composite + bridge
    3. lesson 4
      1. ResourceBundle
    4. lesson 5
      1. implement some specific domain
        1. airplanes
        2. books
        3. musicshop
        4. ...
        5. entity classes with code conventions
      2. use DB
        1. connection pool
        2. data source
      3. add functionality of filtration/search and adding/deletion to the db
      4. collections + generics
      5. patterns
        1. DAO
        2. Command
        3. Memento
        4. View/Controller
        5. Factory
        6. Singleton
        7. ...
      6. resource bundle
        1. db properties
      7. log4j
      8. junit
      9. multithreading
      10. command line interaction
  16. virtual machine
    1. garbage collector
      1. System.gc()
      2. Runtime.getRuntime().gc()
      3. System.runFinalization()
  17. XML
    1. xerces
    2. org.w3c.*
    3. org.xml.*
  18. BookLibrary application
    1. 0.x.1
      1. factory pattern
      2. singleton pattern
      3. command pattern
    2. 0.x.2
      1. patterns
        1. factory
        2. singleton
        3. command
        4. memento
        5. dao
        6. composite
      2. usage
        1. db
          1. filtration
          2. by title
          3. by id
        2. resource bundle
        3. collections
          1. arraylist
        4. enum
    3. 0.x.3
      1. improvements
        1. add some pattern
          1. bridge
          2. builder
          3. strategy
          4. listener
        2. add interactivity
          1. vim-like input
        3. modify factory to create instances of proper classes
        4. logger