Skip to content

Instantly share code, notes, and snippets.

@AndyBowes
AndyBowes / Stack.kt
Created August 1, 2017 16:52
Kotlin Stack Implementation
class Stack<T>{
val elements: MutableList<T> = mutableListOf()
fun isEmpty() = elements.isEmpty()
fun count() = elements.size
fun push(item: T) = elements.add(item)
fun pop() : T? {
val item = elements.lastOrNull()
if (!isEmpty()){
elements.removeAt(elements.size -1)
}
@mscharhag
mscharhag / Java8DateTimeExamples.java
Created February 24, 2014 19:53
Examples for using the Java 8 Date and Time API (JSR 310)
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import static java.time.temporal.TemporalAdjusters.*;
public class Java8DateTimeExamples {