Java Basic Object Oriented Concepts


Lambda: {arguments} -> {statements}

Functional Interface: Comparator, Function, Predicates
Method Reference: Class::method
Default Method: implementation in Interface
Stream: map, reduce, sort, filter
Collectors: joining, toList, summingInt…
Map: putIfAbsent, computeIfPresent, Tree Node (separate chain)
Basic OO in Java
(Class is for code reuse, constructor saves time to initialize)
Data First
A collection of variables and functions
To present  a concept
share some code or has connection (related)
Warrior/Mage/Doctor is a player
Override (same signature, same return value, different method) — Annotation
Abstraction represents different sub-types. (IS-A)
Subclasses have own behaviors.
Runtime Decide.
Player player = new Warrior / Mage / Doctor ();
player.hello(); // ok
player.attack(); // compile error, no attach method in Player class
Encapsulation (security, thread-safe, readability)
High Cohesion, Low Coupling — as inaccessible as possible
Private: this Class
package-private (default): Classes in same package
Protected: Subclasses + Classes in same package
Public: All
Interface vs Abstract Class
Interface (Description) — *able
Unrelated classes implement the interface (e.g. Comparable for human, animal, car)
Define a new data type (e.g. List)
Multiple inheritance types (e.g. List, Deque <= LinkedList)
Abstract Class (Code sharing basics)
Share code among classes
Share common non-public methods, variables
Share code which could change the state of object
If doesn’t share code, use Interface instead of Abstract Class, otherwise use Abstract Class.
from instance to Object, it happens on runtime (i.e. use patch to add some new characters in a game without recompilation)
if (obj instanceof Object) {
class (Class clz = p.getClass())
Everything is class in Java
Class level generics
Method Generics
Bounded Types
class Box<T> { T object }
class Box<T,K,V> { T object,K object2,V object3}
T: type, E: element, K: key, V: value
Raw Type vs Generics
Box b = new Box(); // raw type
Integer c = (Integer) b.get(); // no compile error but runtime error
Box<String> b = new Box<>();
Integer c = (Integer)b.get(); // compiler will complain, will be safer
Generic Method
type (T, K, V) before return value type
Bounded Types
<T extends Comparable<T>>
Wildcards (no declaration beforehand)
public static void process(List<? extends Foo> list) {
  // …
public static void process(List<? super Integer> list) {
  // …
Class: collection, template of instances
Inheritance: reuse, extensibility
Abstraction: share code, template of template
Polymorphism: IS-A, override, runtime decision
Encapsulation: high cohesion, low coupling
Interface: vs Abstract Class
Reflection: from instance to class
Generics: template of classes / methods
Donate $5 to me for a coffee with PayPal and read more professional and interesting technical blog articles about web and mobile development. Feel free to visit my web app, WhizWallet, to apply for credit, store or gift cards, DealsPlus to browse daily deals and store coupons to save money.
Follow me @Yaoli0615 at Twitter to get latest tech updates.

Core Java Volume I–Fundamentals (10th Edition) (Core Series)

Core Java, Volume II–Advanced Features (10th Edition) (Core Series)

Test-Driven Java Development

Java Concurrency in Practice

Java: An Introduction to Problem Solving and Programming (7th Edition)

Java 9 for Programmers (Deitel Developer Series)

Java SE8 for the Really Impatient: A Short Course on the Basics (Java Series)

Core Java for the Impatient

Java: The Beginners Guide for every non-programmer which will attend you trough your learning process

Java Deep Learning Essentials

Machine Learning in Java

Learning Reactive Programming With Java 8

Java 9 Programming By Example

Thinking in Java (4th Edition)

The Java EE Architect’s Handbook, Second Edition: How to be a successful application architect for Java EE applications

Java Artificial Intelligence: Made Easy, w/ Java Programming


About liyao13

Yao Li is a web and iOS developer, blogger and he has a passion for technology and business. In his blogs, he shares code snippets, tutorials, resources and notes to help people develop their skills. Donate $5 to him for a coffee with PayPal at About Me page and read more professional and interesting technical blog articles. Follow him @Yaoli0615 at Twitter to get latest tech updates.
This entry was posted in CS Research&Application, Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s