This file contains hidden or 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.util.List; | |
import java.util.concurrent.*; | |
import java.util.stream.Collectors; | |
import java.util.stream.IntStream; | |
public class Test { | |
public static class MutableInteger { | |
private int val; | |
public MutableInteger() { |
This file contains hidden or 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 ioc; | |
public class Car { | |
private final Engine engine; | |
private int fuel; | |
public Car(Engine engine) { | |
this.engine = engine; | |
} | |
public void addFuel(int fuel) { |
This file contains hidden or 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 Car { | |
private Engine engine; | |
private FuelTank fuelTank; | |
public Car(Engine engine, FuelTank fuelTank) { | |
this.engine = engine; | |
this.fuelTank = fuelTank; | |
} | |
public void start() { |
This file contains hidden or 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.Method; | |
public class ReflectExample { | |
public static void main(String... argv) throws Exception { | |
Animal a = new Dog("Max"); | |
for (Method m : a.getClass().getMethods()) { | |
if (m.getName().startsWith("get") && m.getName().length() > 3 && !m.getName().equals("getClass")) { | |
String property = m.getName().substring(3, 4).toLowerCase() + m.getName().substring(4); |
This file contains hidden or 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
version: '2' | |
services: | |
proxy: | |
image: traefik | |
command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG | |
networks: | |
- webgateway | |
ports: | |
- "80:80" |
This file contains hidden or 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 javax.crypto.Cipher; | |
import java.io.InputStream; | |
import java.security.*; | |
import java.util.Base64; | |
import static java.nio.charset.StandardCharsets.UTF_8; | |
public class RsaExample { | |
public static KeyPair generateKeyPair() throws Exception { | |
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); |
This file contains hidden or 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 Enemy { | |
private int health; | |
public Enemy(int health) { | |
this.health = health; | |
} | |
public void hit(int damage) { | |
health -= damage; | |
} |
This file contains hidden or 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 javax.crypto.Cipher; | |
import java.nio.charset.StandardCharsets; | |
import java.security.KeyPair; | |
import java.security.KeyPairGenerator; | |
import java.security.SecureRandom; | |
import java.security.Signature; | |
public class RsaExample { | |
public static void main(String... argv) throws Exception { | |
//First generate a public/private key pair |
This file contains hidden or 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 test; | |
import shape.*; | |
public class Factorial { | |
public void testRound() { | |
Round round = new Round(); | |
} | |
} |
This file contains hidden or 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 org.junit.Assert; | |
import org.junit.Before; | |
import org.junit.Test; | |
import static junit.framework.TestCase.assertEquals; | |
import static junit.framework.TestCase.fail; | |
public class UnitTestExample { | |
private UnitUnderTest unit; | |
@Before |
NewerOlder