Java
References
Good cheat sheet: https://introcs.cs.princeton.edu/java/11cheatsheet/
Java Sandbox: https://repl.it/languages/java
Tutorials
Oracle Java Documentation: https://docs.oracle.com/javase/tutorial/tutorialLearningPaths.html
Language basics
Classes and Objects: https://docs.oracle.com/javase/tutorial/java/javaOO/index.html
Interfaces and Inheritance: https://docs.oracle.com/javase/tutorial/java/IandI/index.html
Concurrency: https://docs.oracle.com/javase/tutorial/essential/concurrency/index.html
Interactive Tutorials: https://www.learnjavaonline.org/
Packaging Programs in JARs: https://docs.oracle.com/javase/tutorial/deployment/jar/index.html
Baeldung “Back to Basics”: https://www.baeldung.com/java-tutorial
Solutions
ThreadPoolExecutor
Good Example: https://www.journaldev.com/1069/threadpoolexecutor-java-thread-pool-example-executorservice
Pass a List <objects that implement an interface> to a Method
Use: List<? extends YourInterface>
public Interface JsonEnabled {
public String getAsJson();
}
public class User implements JsonEnabled {
....
@Override
public String getAsJson() {...}
}
public class TheServlet {
...
private String getUserListAsJson() {
List<User> userList = this.dao.getUsers();
return this.getListAsJson(userList);
}
private String getListAsJson(List<? extends JsonEnabled> list) { ... }
// The loop code that is in each method.
}
}
Thread Sleep
Example of passing “……” to indicate wait times: https://www.rabbitmq.com/tutorials/tutorial-two-java.html
private static void doWork(String task) throws InterruptedException {
for (char ch: task.toCharArray()) {
if (ch == '.') Thread.sleep(1000);
}
}