#basics
18 snippets tagged with #basics
Reverse a String in Java
Multiple ways to reverse a string in Java including StringBuilder, char array, and stream approaches.
Best for: String manipulation in coding interviews
Java Date/Time API — Modern Operations
Work with LocalDate, LocalDateTime, ZonedDateTime, Duration, Period, and date formatting.
Best for: Date arithmetic and business day calculations
Try-With-Resources and AutoCloseable
Manage resources safely with try-with-resources: files, connections, streams, and custom resources.
Best for: Safe resource management preventing leaks
Null Safety — Elvis, Safe Call, and let
Master Kotlin null safety: safe calls, Elvis operator, let/also scoping, and smart casts.
Best for: Safe navigation through nullable chains
Data Classes — Copy, Destructure, and Equals
Use data classes for immutable models: auto-generated equals, hashCode, copy, and destructuring.
Best for: Immutable domain models and DTOs
Scope Functions — let, run, apply, also, with
Master Kotlin scope functions: when to use let, run, apply, also, and with for concise code.
Best for: Object initialization and configuration
Collections — map, filter, groupBy, and More
Master Kotlin collections: functional transformations, aggregations, grouping, and partition operations.
Best for: Data processing and transformation pipelines
Companion Objects — Static-Like Members and Factories
Use companion objects for factory methods, constants, and implementing interfaces at the class level.
Best for: Factory methods with validated construction
Object Declarations — Singletons and Anonymous
Use object declarations for singletons, anonymous objects, and object expressions in Kotlin.
Best for: Thread-safe singleton services
Enum Classes — Advanced Patterns
Use Kotlin enum classes with properties, methods, interfaces, and companion utilities.
Best for: Type-safe constant sets with behavior
Destructuring Declarations
Destructure objects into variables: data classes, maps, pairs, and custom componentN operators.
Best for: Clean variable extraction from complex objects
Ranges, Progressions, and Coercion
Use Kotlin ranges: IntRange, custom progressions, coerceIn, and range-based iteration patterns.
Best for: Score and category classification
Suspend Functions — Basics and Patterns
Understand suspend functions: sequential vs concurrent, suspend composition, and callback wrapping.
Best for: Sequential vs concurrent API calls
Kotlin Null Safety Complete Guide
Master null safety: safe calls, elvis operator, let/also/run, smart casts, and nullable collection handling.
Best for: Safe handling of nullable data from APIs
Scala Hello World Application
Create a basic Scala application with main method, string interpolation, and val/var basics.
Best for: Getting started with Scala
Pattern Matching Fundamentals
Use Scala pattern matching with guards, type patterns, tuple patterns, and nested extractors.
Best for: Control flow with pattern matching
Tuples and Product Types
Work with Scala 3 tuples: named tuples, tuple operations, conversions, and generic programming.
Best for: Returning multiple values from functions
List Operations Basics
Essential list operations: head, tail, cons, zip, groupBy, sliding, partition, and span.
Best for: Data processing and transformation