<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Day 2: Intermediate Java · Learn Java 25</title>
    <link>https://learn-java-25.pages.dev/03-intermediate-java/index.html</link>
    <description>Streams, object orientation, modules, tooling and concurrency.</description>
    <generator>Hugo</generator>
    <language>en</language>
    <atom:link href="https://learn-java-25.pages.dev/03-intermediate-java/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>More Java Ideas</title>
      <link>https://learn-java-25.pages.dev/03-intermediate-java/09-more-java/index.html</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://learn-java-25.pages.dev/03-intermediate-java/09-more-java/index.html</guid>
      <description>Converting types double d = 42; // widening: automatic int y = (int) 3.99; // narrowing: cast, truncates → 3 int r = (int) Math.round(3.99); // 4 int small = (int) bigLong; // may overflow silently Text ↔ number:&#xA;Integer.parseInt(&#34;42&#34;) Double.parseDouble(&#34;3.14&#34;) Boolean.parseBoolean(&#34;true&#34;) String.valueOf(42) Integer.toString(42) Integer.parseInt(&#34;abc&#34;) // NumberFormatException Integer.parseInt(&#34;ff&#34;, 16) // 255 Integer.toBinaryString(10) // &#34;1010&#34; Integer.toHexString(255) // &#34;ff&#34; 0b1010 0xFF // literals Strings, part 2 &#34;a;b;c&#34;.split(&#34;;&#34;) String.join(&#34;|&#34;, parts) &#34;line1\nline2&#34;.lines().toList() &#34;abc&#34;.compareTo(&#34;abd&#34;) // negative &#34;Hello&#34;.toCharArray() &#34;%-10s|&#34;.formatted(&#34;left&#34;) // &#34;left |&#34; &#34;%,.2f&#34;.formatted(1234567.891) // &#34;1,234,567.89&#34; &#34;%08.3f&#34;.formatted(3.14159) // &#34;0003.142&#34; String.format(Locale.US, &#34;%,.2f&#34;, 1999.5); Enums A type with a fixed set of values:</description>
    </item>
    <item>
      <title>Lambdas &amp; Streams</title>
      <link>https://learn-java-25.pages.dev/03-intermediate-java/10-streams/index.html</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://learn-java-25.pages.dev/03-intermediate-java/10-streams/index.html</guid>
      <description>Lambdas A lambda is an unnamed function. It fits anywhere a functional interface — an interface with exactly one method — is expected.&#xA;Runnable task = () -&gt; IO.println(&#34;running&#34;); Predicate&lt;String&gt; isLong = s -&gt; s.length() &gt; 5; BinaryOperator&lt;Integer&gt; add = (a, b) -&gt; a + b; Function&lt;String, String&gt; pretty = s -&gt; { var t = s.strip().toLowerCase(); return t.substring(0, 1).toUpperCase() + t.substring(1); }; Interface Shape Used by Predicate&lt;T&gt; T → boolean filter Function&lt;T,R&gt; T → R map Consumer&lt;T&gt; T → void forEach Supplier&lt;T&gt; () → T lazy values UnaryOperator&lt;T&gt; T → T replaceAll Comparator&lt;T&gt; (T,T) → int sorted Method references s -&gt; s.toUpperCase() → String::toUpperCase s -&gt; IO.println(s) → IO::println s -&gt; Integer.parseInt(s) → Integer::parseInt () -&gt; new ArrayList&lt;&gt;() → ArrayList::new x -&gt; obj.handle(x) → obj::handle Streams Source → any number of intermediate steps → exactly one terminal operation.</description>
    </item>
    <item>
      <title>Object Oriented Java</title>
      <link>https://learn-java-25.pages.dev/03-intermediate-java/11-oop/index.html</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://learn-java-25.pages.dev/03-intermediate-java/11-oop/index.html</guid>
      <description>Classes public class Account { private final String owner; // state private long cents; public Account(String owner, long opening) { // constructor this.owner = owner; this.cents = opening; } public void deposit(long amount) { // behaviour if (amount &lt;= 0) throw new IllegalArgumentException(&#34;must be positive&#34;); cents += amount; } public long balance() { return cents; } } var account = new Account(&#34;Ann&#34;, 10_000); account.deposit(5_000); Modifier Visible in private the same class (none) the same package protected package + subclasses public everywhere Fields private, methods as narrow as possible.</description>
    </item>
    <item>
      <title>Exceptions</title>
      <link>https://learn-java-25.pages.dev/03-intermediate-java/12-exceptions/index.html</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://learn-java-25.pages.dev/03-intermediate-java/12-exceptions/index.html</guid>
      <description>Throwable ├── Error ← JVM problems, do not catch │ ├── OutOfMemoryError │ └── StackOverflowError └── Exception ├── RuntimeException ← unchecked │ ├── NullPointerException │ ├── IllegalArgumentException │ ├── IllegalStateException │ └── NumberFormatException └── IOException ← checked Checked exceptions describe expected trouble from the outside world; the caller must handle or declare them. Unchecked ones usually mean a bug.&#xA;try { var text = Files.readString(path); } catch (IOException e) { IO.println(&#34;cannot read: &#34; + e.getMessage()); } String read(Path p) throws IOException { // or pass it up return Files.readString(p); } try / catch / finally try { risky(); } catch (NumberFormatException e) { // specific first … } catch (RuntimeException e) { // general later … } finally { // always runs } e.getMessage() e.getCause() e.getStackTrace() e.printStackTrace() // debugging only try-with-resources Anything AutoCloseable is closed for you, in reverse order, even on failure:</description>
    </item>
    <item>
      <title>Packages, Modules &amp; Libraries</title>
      <link>https://learn-java-25.pages.dev/03-intermediate-java/13-modules/index.html</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://learn-java-25.pages.dev/03-intermediate-java/13-modules/index.html</guid>
      <description>Packages A package is a namespace and a directory, named after your reversed domain:&#xA;src/com/example/shop/Cart.java src/com/example/shop/pricing/Discount.java package com.example.shop; import com.example.shop.pricing.Discount; import java.util.List; import java.util.List; // one class import java.util.*; // whole package (rare in projects) import static java.lang.Math.PI; // static member java.lang (with String, Math, IO) is always imported.</description>
    </item>
    <item>
      <title>Command Line Tools</title>
      <link>https://learn-java-25.pages.dev/03-intermediate-java/14-cli-tools/index.html</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://learn-java-25.pages.dev/03-intermediate-java/14-cli-tools/index.html</guid>
      <description>Reading input void main() { var name = IO.readln(&#34;Your name? &#34;); IO.println(&#34;Hello, &#34; + name + &#34;!&#34;); } IO.readln returns null at end of input (Ctrl+D, or redirected files) — check for it.&#xA;The classic way:&#xA;var scanner = new Scanner(System.in); var n = scanner.nextInt(); scanner.nextLine(); // consume the rest of the line! var text = scanner.nextLine(); Warning nextInt() leaves the newline behind, so the next nextLine() returns empty. Safer: read whole lines and parse them yourself.</description>
    </item>
    <item>
      <title>Virtual Threads &amp; Concurrency</title>
      <link>https://learn-java-25.pages.dev/03-intermediate-java/15-concurrency/index.html</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://learn-java-25.pages.dev/03-intermediate-java/15-concurrency/index.html</guid>
      <description>A classic platform thread maps to an OS thread: ~1 MB of stack, expensive to create, so they were pooled and rationed.&#xA;var t = new Thread(() -&gt; IO.println(&#34;in parallel&#34;)); t.start(); t.join(); Virtual threads Managed by the JVM, not the OS. They cost almost nothing, and when one blocks it releases its carrier thread.</description>
    </item>
    <item>
      <title>Tests &amp; Web Frameworks</title>
      <link>https://learn-java-25.pages.dev/03-intermediate-java/16-tests-web/index.html</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://learn-java-25.pages.dev/03-intermediate-java/16-tests-web/index.html</guid>
      <description>A test is code that checks other code. The payoff is not in writing it — it is in changing code later without guessing what you broke.&#xA;JUnit 5 &lt;dependency&gt; &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt; &lt;artifactId&gt;junit-jupiter&lt;/artifactId&gt; &lt;version&gt;5.11.4&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; Tests live in src/test/java, mirroring the package structure.&#xA;import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; class DiscountTest { @Test void tenPercentOffOneHundred() { var discount = new Discount(0.10); // arrange var result = discount.applyTo(10_000); // act assertEquals(9_000, result); // assert } @Test void negativeDiscountIsRejected() { assertThrows(IllegalArgumentException.class, () -&gt; new Discount(-0.1)); } } mvn test One behaviour per test, and the method name states the rule — not the method being called.</description>
    </item>
  </channel>
</rss>