Skip to content

karol-preiskorn/java-blockchain

Repository files navigation

📚 Java Examples & Blockchain Implementation

A collection of Java tutorials, examples, and exercises covering core Java concepts and blockchain implementation.

📖 Table of Contents


🔄 Collections & Type Casting

Casting Type

Learn about type safety and unchecked casting in Java:

Collections

Nested Collections & HashTable

Explore collections with the HashTable class implementation:

import java.util.Hashtable;

class HashTable {
    public static void main(String[] arg) {
        // Creating a hash table
        Hashtable<Integer, String> h = new Hashtable<Integer, String>();

        h.put(3, "Geeks");
        h.put(2, "forGeeks");
        h.put(1, "isBest");
        h.put(4, "Quamm");
        h.put(5, "Qq");
        h.put(6, "Qq");

        // Create a clone or shallow copy of hash table h
        Hashtable<Integer, String> h1 = (Hashtable<Integer, String>) h.clone();
        Hashtable<Integer, String> h2 = (Hashtable<Integer, String>) h1.clone();

        System.out.println("-- start --");
        System.out.println(">h: " + h);
        System.out.println("clone h->h1: " + h1);

        // Clear hash table h
        h.clear();

        // Checking hash table h
        System.out.println("after clearing h: " + h);
        System.out.println(">h1: " + h1);
        System.out.println(">h2: " + h2);

        // Proper way to create a clone of hash table
        Hashtable<?, ?> h3 = (Hashtable<?, ?>) h.clone();
        System.out.println(">(String) h3: " + h3);
    }
}

Key Classes:

  • 📁 HashTable.java - Hashtable implementation examples
  • 📁 Vehicle.java - Vehicle class hierarchy examples
  • 📁 CollectionsEx1.java - Nested collections examples
  • 📁 OptionalBasicExample.java - Optional API examples

⛓️ Blockchain Implementation

A simple blockchain implementation built with Java, based on industry best practices and detailed articles.

Resources

Core Components

  • Block.java 🧱 - Represents individual blocks in the blockchain chain
  • NoobChain.java ⛓️ - Basic blockchain implementation
  • NoobChainV2.java ⛓️ - Enhanced blockchain with transactions
  • StringUtil.java 🔧 - Utility functions for blockchain operations
  • Transaction.java 💰 - Transaction handling
  • TransactionInput.java 📥 - Transaction input management
  • TransactionOutput.java 📤 - Transaction output management
  • Wallet.java 💳 - Wallet functionality for blockchain

📋 Project History

Date Event
2019-11-03 Added Gradle configuration for log4j2 JAR generation
2019-11-06 Added blockchain package
2020-02-14 Updated README.md documentation

🚀 Getting Started

# Build the project
./gradlew build

# Run tests
./gradlew test

📝 License & Attribution

This project contains examples and tutorials referenced from various sources including Medium and UltimaSolution blog posts.

About

Java Blockchain (example simple implemenatation))

Topics

Resources

Stars

Watchers

Forks