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.Iterator; | |
public class LinkedStack<E> implements Iterable<E> { | |
private Node<E> head = null; | |
private int size = 0; | |
@Override | |
public Iterator iterator(){return new StackIterator();} | |
private class StackIterator implements Iterator<E> { |
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.NoSuchElementException; | |
public class LinkedQueue<E> { | |
private Node<E> first, last; | |
private class Node<E>{ | |
E content; | |
Node<E> next = null; | |
} | |
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.Iterator; | |
import java.util.NoSuchElementException; | |
public class LinkedDeque<E> implements Iterable<E>{ | |
private final Node<E> first, last; | |
private int size; | |
private class Node<E> { | |
E content; |
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.ArrayList; | |
public class GenericArray <T>{ | |
private ArrayList<T> arrayList; | |
private Object[] array; | |
// constructor with parameter ArrayList | |
public GenericArray(ArrayList<T> list){ | |
arrayList = list; |
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 int second(int[] array){ | |
if(array.length < 2) throw new IllegalStateException("minimum length of array must be 2"); | |
int max = Integer.MIN_VALUE; | |
int second = 0; | |
int counter = 0; | |
for(int i = 0; i < array.length; i++){ | |
if(array[i] > max) { | |
second = max; | |
counter++; |
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
///usr/bin/env jbang "$0" "$@" ; exit $? | |
//DEPS io.vertx:vertx-rx-java3:4.2.5 | |
//DEPS io.vertx:vertx-web-client:4.2.5 | |
import io.reactivex.rxjava3.core.Single; | |
import io.vertx.rxjava3.core.Vertx; | |
import io.vertx.rxjava3.ext.web.client.HttpResponse; | |
import io.vertx.rxjava3.ext.web.client.WebClient; | |
import java.util.AbstractMap; |
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
static void eager(OurObject object){ | |
System.out.println("Eager thinks it didn't do anything"); | |
} | |
static void lazy(Supplier<OurObject> ourObjectSupplier){ | |
System.out.println("Lazy is sure it didn't do anything"); | |
} |
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
///usr/bin/env jbang "$0" "$@" ; exit $? | |
import static java.lang.System.*; | |
import java.util.List; | |
import java.util.function.Supplier; | |
import java.util.stream.Stream; | |
public final class SupplierExample { | |
public static void main(String[] args) { |