Convert an Object to Map in Java: Jackson, Gson and Reflection
Convert an object to Map in Java with Jackson 3 convertValue(), JavaPropsMapper flat keys, Gson and reflection, plus nulls, records and Map back to object.
“Core Java” is Sun’s term, used to refer to Java SE, the standard edition and a set of related technologies, like the Java VM, CORBA, etc. This is mostly to differentiate from others like Java ME or Java EE. “Core Java” is Oracle’s definition and refers to subset of Java SE technologies.
The Core Java technologies and application programming interfaces (APIs) are the foundation of the Java Platform, Standard Edition (Java SE). They are used in all classes of Java programming, from desktop applications to Java EE applications.
Convert an object to Map in Java with Jackson 3 convertValue(), JavaPropsMapper flat keys, Gson and reflection, plus nulls, records and Map back to object.
Learn to filter a map by a list of keys in Java with get() lookups, streams and retainAll(), keep the key order and report the keys that are missing.
IllegalMonitorStateException in Java explained, with every cause from wait() and notify() outside synchronized to ReentrantLock unlock() and the fixes.
Learn how to round a double to 2 decimal places in Java with BigDecimal, Math.round(), String.format() and DecimalFormat, plus rounding modes and pitfalls.
Invert a map in Java by swapping keys and values with a loop or Collectors.toMap(), handle duplicate values with groupingBy(), and use Guava BiMap.
Java printf examples for %s, %d, %.2f, width, flags, dates and locales, plus String.format(), formatted() and fixes for common format exceptions.
Java thread join() waits for another thread to finish. Learn join(long), join(Duration), interrupts, deadlocks, visibility and yield() vs join().
Learn XmlAssert, the AssertJ API of XMLUnit, to check XML in Java tests by XPath, compare documents, ignore order and whitespace, and validate XSD.
Learn XMLUnit 2 to compare XML in Java tests, with identical vs similar checks, element order, whitespace, node filters and DifferenceEvaluator examples.
Learn JSONassert to compare JSON in Java tests, with LENIENT vs STRICT modes, arrays, failure messages, ignored fields and a REST response example.
Java HashMap guide with examples for put, get, merge, compute, iteration, keys, internals and thread safety, plus links to every HashMap how-to.
Java concurrency explained for Java 25 with thread safety, a race condition fix, a timeline from Java 1.0 to 25 and all our tutorials grouped by task.
Learn the Java Collections Framework with a Java 21 hierarchy diagram, how to choose List, Set, Map and Queue classes, and links to every tutorial.
Learn the Java ArrayList with tested examples for get(), size() vs capacity, subList(), ensureCapacity(), sorting, streams and Java 21 getFirst().
The Java List interface explained with examples of List.of(), positional methods, Java 21 sequenced methods and how to choose an implementation.
A Java Map stores unique keys with one value each. Quick put/get/merge/computeIfAbsent examples, a comparison of HashMap, LinkedHashMap, TreeMap, ConcurrentHashMap, EnumMap, Hashtable and Map.of(), and all our Map tutorials grouped by topic.
Create a Java case insensitive map with TreeMap and CASE_INSENSITIVE_ORDER, Commons CaseInsensitiveMap or Spring LinkedCaseInsensitiveMap, side by side.
Learn to create and start a thread in Java with Runnable, Thread, Thread.ofPlatform(), virtual threads, ExecutorService, ThreadFactory and priority.
Java EnumMap stores enum keys in an array by ordinal. Learn its constructors, null rules, key order, stream collectors and how it differs from HashMap.
Learn Jayway JsonPath 3 in Java with operators, filters, functions, typed reads with Jackson, missing-path options and updates, with runnable examples.
REST-assured POST request examples with JSON body as String, Map, POJO or file, plus PUT and PATCH, headers, auth, response checks and extraction.
How to remove last character from a string in Java with substring(), StringBuilder, regex and chop(), safe for null, empty strings and emoji.
REST-assured XML request guide. Send XML from a String, file or JAXB object, set the charset, and validate responses with GPath, XPath and XmlPath.
REST-assured tutorial for API testing in Java with JUnit. Learn given/when/then, GPath checks, extraction, specifications, auth and schema validation.
Create a Java nested map with computeIfAbsent and streams, add, remove and iterate entries, read values safely, deep copy, flatten and choose alternatives.
Immutable vs unmodifiable map in Java explained with Map.of(), Map.copyOf(), Collections.unmodifiableMap(), toUnmodifiableMap() and Guava ImmutableMap.
Collect stream to immutable list in Java with toList() or Collectors.toUnmodifiableList(), how nulls differ, plus unmodifiable Set and Map collectors.
TreeMap vs HashMap in Java compared on ordering, speed, null keys, memory and key equality, with Java 25 examples and a table for picking the right map.
How to kill a thread in Java safely with interrupt() or a volatile flag, why Thread.stop() throws UnsupportedOperationException and how to stop tasks.
Append rows to an existing Excel sheet with Apache POI 5.5.1. We find the next free row, keep the date and number formats, add rows before a totals row and save through a temp file so a failed write never empties the spreadsheet.
Set and get the thread name in Java with getName(), setName(), constructors and Thread builders, default names, executor thread names and threadId().
Read large Excel files with the Apache POI SAX parser and XSSFSheetXMLHandler, handle missing cells and dates, import in batches, write with SXSSF.
Java IdentityHashMap compares keys with == instead of equals(). Learn how it differs from HashMap, the String and Integer traps and the Java 20 change.
Java ConcurrentMap with putIfAbsent, compute and merge examples, why get-then-put loses updates, null rules and ConcurrentHashMap vs ConcurrentSkipListMap.
Learn to debug Java streams with peek(), lambda breakpoints and the IntelliJ Trace Current Stream Chain action, and avoid the peek() and count() traps.
Java wait for all threads to finish with ExecutorService close(), invokeAll(), Future.get(), CountDownLatch, CompletableFuture.allOf() and join().
Learn how Java WeakHashMap removes entries after GC clears weak keys, the String and value-reference traps, WeakHashMap vs HashMap and real use cases.
The ternary operator in Java with examples covering syntax, result types, the null unboxing trap, nested ternaries and when to use if-else instead.
Java structured concurrency with the Java 25 preview API. Learn StructuredTaskScope.open(), fork, join, Joiners, timeouts, custom joiners and the flags.
Java virtual threads explained for Java 25 with examples, carrier threads, the Java 24 pinning fix, when not to use them, pooling and ThreadLocal pitfalls.
EasyMock tutorial with JUnit 5. Create mocks, record expectations, replay and verify, mock void methods, use matchers, captures and nice or strict mocks.
Test Spring WebClient with MockWebServer and JUnit. Queue responses, route with a Dispatcher, verify requests, and simulate errors, delays and timeouts.
WireMock 3 tutorial for Java. Stub REST APIs in JUnit 5 tests, match requests, simulate delays and faults, verify calls and use stateful scenarios.
Copy an InputStream to OutputStream in Java with transferTo(), a custom loop, Files.copy(), Guava or Commons IO, plus the closing and flushing rules.
Convert a Reader to InputStream in Java with a String, OutputStreamWriter or Commons IO ReaderInputStream, and back with InputStreamReader and a charset.
Java create directory examples with Files.createDirectories() and createDirectory(), parent folders, permissions, mkdirs() pitfalls and race-free checks.
Count lines in a file in Java with Files.lines(), LineNumberReader, readAllLines() or a fast byte counter, with edge cases like a missing final newline.
Java check if directory is empty with Files.list() or newDirectoryStream(), closing the stream, files and missing paths, hidden files and subfolders.
Read the file creation date in Java with BasicFileAttributes, format the FileTime, and see which platforms and JDK versions return the real value.
Create, detect and read symbolic links in Java with Files, control link following with NOFOLLOW_LINKS, compare hard links and switch releases atomically.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.