Skip to content

Instantly share code, notes, and snippets.

@tamboer
tamboer / Calculator.java
Created December 16, 2017 12:35 — forked from LazaroIbanez/Calculator.java
Java 8 Lambda Expressions
public class Calculator {
interface IntegerMath {
int operation(int a, int b);
}
public int operateBinary(int a, int b, IntegerMath op) {
return op.operation(a, b);
}
@tamboer
tamboer / kafka_commands.md
Created December 16, 2017 11:58 — forked from golonzovsky/kafka_commands.md
useful Kafka commands

TODO

  • kafkacat commands

some useful comands

start cluster locally with port forward or host network

docker run -d --name=landoop -p 127.0.0.1:8081-8083:8081-8083 -p 127.0.0.1:9581-9585:9581-9585 -p 127.0.0.1:9092:9092 -p 127.0.0.1:3030:3030 -p 127.0.0.1:2181:2181 -e ADV_HOST=127.0.0.1 landoop/fast-data-dev

package com.golonzovsky.streams;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.junit.Before;
import org.junit.Test;
import java.io.BufferedReader;
import java.io.FileReader;
import java.time.Year;
@tamboer
tamboer / java serialization.md
Created December 16, 2017 11:50
java serialization

Serialization

What serialization is?

If you take an object and serialize it, that means turning that object into binary form or binary data. De serialize means take binary data and turn it back into an object.

TODO Serialization example

@tamboer
tamboer / StackOverFlow.md
Created December 16, 2017 11:45
Java stack overflow - Stack and Heap

Stack and Heap

Recursion

The following code will generate an error

public class App {

	public static void main(String[] args) {
		int value = 4;
 calculate(value);
@tamboer
tamboer / StringsInJava.md
Created December 16, 2017 11:37
Java Strings

String bulider and string formatting

?Every time you are putting a plus between two strings you are creating a new string.

In Java strings are immutable, once you create a string you can never change it. It looks like you changed it , but it's not true. You are creating a new string, you are not appending to the existing string.

StringBuilder

Use StringBuilder class instead. StringBuilder appends new content, it does not

@tamboer
tamboer / java-do-while-with-user-input.java
Created December 16, 2017 11:28
Java do while with user input
Scanner userinput = new Scanner(System.in);
int value;
do{
System.out.println("Enter an integer value: ");
value = userinput.nextInt();
}while(value !=5);
System.out.println("Got 5!");
@tamboer
tamboer / collection-java-tutorial.java
Created December 16, 2017 11:22 — forked from nijjwal/collection-java-tutorial.java
collection-java-tutorial.java
//This is my note for Java Collection Framework course taught by John.
//Original credit: John from caveofprogramming.com
//All of his videos can be found in youtube.com
/**---------------------------------
| 1. ArrayList
|
*/---------------------------------
1.
-ArrayList class implements the class that is expandable.
@tamboer
tamboer / SnoepAutomaat.java
Last active August 29, 2015 14:11
javaSnoepAutomaat
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
//package oefs;
import java.util.Scanner;
/**
@tamboer
tamboer / CheckBTW.java
Created December 9, 2014 10:09
Java CheckBTW
import java.util.Formatter;
import java.util.Scanner;
public class CheckBTW{
public static void main(String args[]){
System.out.print("Geef een getal: ");