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
export class Y { | |
} |
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 abstract class OverridableFromConstructor { | |
OverridableFromConstructor() { | |
test(); | |
} | |
protected abstract void test(); | |
static class SubClass extends OverridableFromConstructor { | |
private int i = 10; |
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
import java.lang.reflect.Field; | |
import java.util.HashMap; | |
public class MapTest { | |
private static class X { | |
private int value; | |
public X(int value) { | |
this.value = value; |
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 class SwingTest { | |
public static void main(String[] args) { | |
SwingUtilities.invokeLater(() -> { | |
Block b = new Block("block1"); | |
Block bb = new Block("block2"); | |
JFrame jf = new JFrame(); |
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
fun main(args: Array<String>) { | |
val map = HashMap<String, String>() | |
map.iterator().remove(); | |
} |
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.threads; | |
/** | |
* demonstrate race conditions | |
*/ | |
public class Step4 { | |
private int a; | |
public int getA() { |
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 class ThreadTest { | |
private volatile boolean stop = false; | |
public void test() throws Exception { | |
new Thread(() -> { | |
while (!stop) { | |
} |
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
import java.security.NoSuchAlgorithmException; | |
import java.security.Security; | |
import java.util.Base64; | |
import javax.crypto.Cipher; | |
import javax.crypto.KeyGenerator; | |
import javax.crypto.SecretKey; | |
import javax.crypto.spec.SecretKeySpec; | |
public class Encryption { |
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
JButton addItemButton = new JButton("Add Item with icon"); | |
addItemButton.addActionListener(e -> { | |
map.put("foo", load("https://i.imgur.com/tSiZYyw.png")); | |
testBox.addItem("foo"); | |
}); | |
add(addItemButton); |
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
data class Student(val id: String, var name: String? = null) | |
fun main(args: Array<String>) { | |
val list = mutableListOf(Student("a", "John"), Student("b", "Jane")) | |
list.filter { l -> l.id == "b" } | |
.map { l -> l.name = "Jack" } | |
.toList() | |
println("list = ${list}") | |
} |