Skip to content

Add 80 comprehensive Java data types examples to data-types.md#7

Merged
janbodnar merged 2 commits intomainfrom
copilot/fix-d09bf517-e794-4d4f-99e4-fbf5ba6654a4
Oct 7, 2025
Merged

Add 80 comprehensive Java data types examples to data-types.md#7
janbodnar merged 2 commits intomainfrom
copilot/fix-d09bf517-e794-4d4f-99e4-fbf5ba6654a4

Conversation

Copy link
Contributor

Copilot AI commented Oct 7, 2025

This PR adds a comprehensive guide to Java data types with 80 progressively advanced examples covering all major aspects of type representation, manipulation, and conversion in modern Java.

What's New

Created data-types.md with detailed examples demonstrating:

Core Data Types

  • Primitive types: int, double, boolean, char, byte, short, long, float
  • Reference types: String, List, Map, Set, and arrays
  • Wrapper classes: Integer, Double, Boolean, Character

Type Operations

  • Autoboxing/Unboxing: Automatic conversion between primitives and wrappers
  • Type Conversion: Widening/narrowing conversions, explicit casting
  • String Conversions: Parsing strings to primitives and vice versa

Modern Java Features

  • Type Inference: Using var with primitives, collections, and generics
  • Optional: Null-safe operations with Optional.of(), Optional.empty(), orElse()
  • Pattern Matching: Type checking with instanceof patterns
  • Records & Sealed Types: Modern immutable data carriers

Advanced Concepts

  • Collections: Type-safe operations with List, Map, Set, ArrayList, HashMap
  • Generics: Type bounds, wildcards, type erasure
  • Comparison: Primitive vs reference equality, Comparable interface
  • Precision Types: BigInteger and BigDecimal for arbitrary precision
  • Concurrent Types: Atomic types for thread-safe operations

Implementation Details

All examples follow Java 25 syntax:

  • ✅ Compact source file format with instance main methods
  • ✅ Implicit imports (IO, List, Map, Set, ArrayList, HashMap)
  • ✅ Type inference with var where appropriate
  • ✅ Modern features like records, sealed interfaces, and type patterns

Examples are structured progressively from basic concepts (simple int/double types) to advanced patterns (type-safe heterogeneous containers, generic type bounds, atomic operations).

Each example includes:

  • Concise, runnable code using void main()
  • Clear description (max 80 chars/line) explaining the concept
  • Practical demonstration of the type or operation

Formatting

Follows repository style guidelines:

  • Descriptions limited to 80 characters per line with two-space endings
  • No numbered section titles (plain descriptive names)
  • Consistent with existing documentation (strings.md, conditionals.md)
  • Functions referenced without parentheses

Fixes #<issue_number>

Original prompt

On data-types.md, Create 80 concise and progressively advanced Java examples that showcase the usage of Java data types. Each example should highlight a distinct type or concept related to data representation, manipulation, or conversion.

✅ Requirements

  • Use modern Java syntax, including features up to Java 25:
    • Compact source files
    • Instance main methods
    • Type inference with var
    • Implicit imports (List, Map, IO, etc.)
  • Cover a variety of data types and related topics:
    • Primitive types (int, double, boolean, char, byte, short, long, float)
    • Reference types (String, List, Map, Set, arrays)
    • Type inference with var
    • Wrapper classes (Integer, Double, etc.)
    • Autoboxing and unboxing
    • Type conversion and casting
    • Default values and initialization
    • Nullability and Optional
    • Using data types in collections
    • Comparison and equality

📄 Format

void main() {

    int age = 30;              
    double pi = 3.1415;           
    String name = "Java";         
    boolean isFun = true;        

    IO.println(name + " is fun: " + isFun + ", age: " + age + ", pi: " + pi);
}

Description:
Demonstrates usage of primitive and reference types with type inference.

🧠 Style Guidelines

  • Use compact source file format (no class or static method unless necessary)
  • Prefer IO.println for output
  • Use var for type inference
  • Keep examples readable and runnable
  • Include a description (max 80 characters per line, two-space line endings)
  • Refer to functions without parentheses (e.g. the main function)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: janbodnar <16985640+janbodnar@users.noreply.github.com>
Copilot AI changed the title Create **80 concise and progressively advanced Java examples** that showcase the usage of **Java data types**. Each example should highlight a distinct type or concept related to data representation, manipulation, or conversion. ### ✅ Requirements - ... Add 80 comprehensive Java data types examples to data-types.md Oct 7, 2025
Copilot AI requested a review from janbodnar October 7, 2025 09:32
@janbodnar janbodnar closed this Oct 7, 2025
@janbodnar janbodnar reopened this Oct 7, 2025
@janbodnar janbodnar marked this pull request as ready for review October 7, 2025 09:48
@janbodnar janbodnar merged commit 25d725a into main Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants