java-fundamentals

Guides writing idiomatic Java code covering syntax, OOP, collections, streams, and exception handling.

Updated Jun 28, 2026
One-click install
npx skills add https://github.com/412181-HerediaLara/ScaffoldingBE-FE --skill java-fundamentals-412181-heredialara
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: java-fundamentals
Source: https://github.com/412181-HerediaLara/ScaffoldingBE-FE/tree/main/BE/.agents/skills/java-fundamentals
Command: npx skills add https://github.com/412181-HerediaLara/ScaffoldingBE-FE --skill java-fundamentals-412181-heredialara

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pyyaml, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve? Developers often struggle to recall correct Java idioms, choose the right collection type, or apply modern language features like records and pattern matching consistently across Java 8 through 21. ## Core Features & Use Cases - Core Language Guidance: Covers syntax, OOP principles, generics, and modern features such as records, sealed classes, and pattern matching for Java 8-21. - Collections & Streams Reference: Provides selection criteria for ArrayList, HashMap, TreeSet, and other structures, plus Stream API patterns with filter, map, reduce, and Optional handling. - Exception Handling Patterns: Explains checked versus unchecked exceptions, try-with-resources, and custom exception design. - Use Case: When refactoring legacy Java code, use this Skill to modernize loops into streams, replace anonymous classes with lambdas, and apply records for immutable data carriers. ## Quick Start Ask the assistant to review your Java class and suggest improvements using modern Java 21 features like records, sealed classes, and pattern matching.

Frequently Asked Questions about java-fundamentals

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose between ArrayList, HashSet, and HashMap in Java?

Choose ArrayList for indexed access with O(1) random access, HashSet for unique elements with O(1) contains checks, and HashMap for key-value pairs with O(1) get and put. Use TreeSet when you need sorted unique elements at O(log n) cost.

How to convert Java loops into Stream API operations?

Replace iteration loops with stream pipelines using filter, map, and collect or toList. For example, users.stream().filter(User::isActive).map(User::getName).sorted().toList() replaces a manual loop with conditional collection.

Does Java pattern matching work with switch expressions?

Yes, Java 21 supports pattern matching in switch expressions, allowing type checks and casts in case labels. You can match Integer, String, and other types directly with guarded patterns, eliminating manual instanceof and cast chains.

What causes ConcurrentModificationException in Java collections?

ConcurrentModificationException occurs when a collection is structurally modified during iteration outside the iterator. Fix it by using Iterator.remove(), collecting items to remove first, or using concurrent collections like ConcurrentHashMap.

When should I use Optional instead of null checks in Java?

Use Optional as a return type when a method may legitimately return no value, signaling absence explicitly to callers. Chain operations with map, flatMap, and orElse instead of nested null checks, but avoid Optional for fields or parameters.