This file contains 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.codinko; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
import java.util.List; | |
public class ConcurrentModificationExceptionDemo { | |
public static void main(String[] args) { | |
new ConcurrentModificationExceptionDemo().method1(); | |
} |
This file contains 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.codinko; | |
public class GenericClassT<T> { | |
private T t; | |
public T get() { | |
return this.t; | |
} |
This file contains 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.codinko.generics; | |
public class GenericClass<T> { | |
private T t; | |
public T get() { | |
return this.t; | |
} |
This file contains 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.codinko.example; | |
/** | |
* | |
* Feel free to play around with this code to try various topics covered under Threads & Locks: | |
* | |
* Theory reference: https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html | |
* | |
*/ | |
public class ThreadWaitDemo { |
This file contains 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
/* | |
Output WITHOUT Join [although the mix sequence could vary but inconsistent] | |
Thread 1 arrived... | |
Thread 2 arrived... | |
Thread 1 working on 1... | |
Thread 2 working on 1... | |
Thread 1 working on 2... | |
Thread 2 working on 2... | |
Thread 2 working on 3... |
This file contains 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.codinko.sample; | |
import java.util.HashMap; | |
import java.util.Map.Entry; | |
import java.util.TreeMap; | |
public class CompareTreeMapHashMap { | |
public static void main(String[] args) { | |
Employee emp1 = new Employee("Harley", 100); | |
Employee emp2 = new Employee("Peter", 100); |
This file contains 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.codinko.sample; | |
public class Employee { | |
String name; | |
Employee(String name) { | |
this.name = name; | |
} | |
@Override |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
function clickCounter() { | |
if(typeof(Storage) !== "undefined") { | |
if (sessionStorage.clickcount) { | |
sessionStorage.clickcount = Number(sessionStorage.clickcount)+1; | |
} else { | |
sessionStorage.clickcount = 1; |
This file contains 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 enum CarType { | |
SMALL, LUXURY | |
} | |
public Interface class Car { // abstract class or Interface. | |
} | |
public class CarFactory { | |
public static Car buildCar(CarType model) { | |
Car car = null; |
OlderNewer