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 org.apache.commons.beanutils.BeanUtils; | |
import java.lang.reflect.InvocationTargetException; | |
import java.util.ArrayList; | |
import java.util.List; | |
/** | |
* Created by koduki on 1/30/14. | |
*/ | |
public class Main { |
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.util.Arrays; | |
import java.util.List; | |
/** | |
* | |
* @author koduki | |
*/ | |
public class HelloJDK8 { | |
/** |
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
class Person implements Compare { | |
public Person self(){ return this; } | |
public String getName(){ | |
return "Koduki"; | |
} | |
} | |
interface Compare<T> { | |
T self(); | |
default boolean compare(T x){ |
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.util.stream.IntStream; | |
/** | |
* | |
* @author koduki | |
*/ | |
public class FizzBuzz { | |
public static void main(String[] args) { | |
fizzBuzzWithOldStyle(); |
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
/** | |
* Ancient Style. | |
*/ | |
public static void useWile() { | |
int i = 1; | |
while (i <= 100) { | |
if (i % 15 == 0) { | |
System.out.println("FizzBuzz"); | |
} else if (i % 3 == 0) { | |
System.out.println("Fizz"); |
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
/** | |
* Lost Magic. | |
*/ | |
public static void useGoto() { | |
int i = 1; | |
LOOP: | |
if (i <= 100) { | |
if (i % 15 == 0) { | |
System.out.println("FizzBuzz"); | |
} else if (i % 3 == 0) { |
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
/** | |
* Old Style. | |
*/ | |
public static void useForLoop() { | |
for (int i = 1; i <= 100; i++) { | |
if (i % 15 == 0) { | |
System.out.println("FizzBuzz"); | |
} else if (i % 3 == 0) { | |
System.out.println("Fizz"); | |
} else if (i % 5 == 0) { |
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
/** | |
* Java 8 New Style. | |
*/ | |
public static void useStreamAPI() { | |
String line = IntStream.rangeClosed(1, 100).boxed() | |
.map(n | |
-> (n % 15 == 0) ? "FizzBuzz" | |
: (n % 3 == 0) ? "Fizz" | |
: (n % 5 == 0) ? "Buzz" | |
: n.toString()) |
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 static void useList() { | |
List<String> result = fizzbuzz(); | |
for (String x : result) { | |
System.out.println(x); | |
} | |
} | |
public static List<String> fizzbuzz() { | |
List<String> result = new ArrayList<>(); |
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 static void useList() { | |
List<String> result = fizzbuzz(list(1, 100)); | |
for (String x : result) { | |
System.out.println(x); | |
} | |
} | |
public static List<String> fizzbuzz(List<Integer> source) { | |
List<String> result = new ArrayList<>(); |
OlderNewer