Skip to content

Java for C# developers — Mission

I think in C#. But much of the code I read every day is Java: Spring services, build plugins, libraries whose C# port lags behind. The two languages look so alike that it is easy to write Java as if it were C#, and to be surprised at run time: == on two Integers, a generic type that has vanished, a checked exception that won’t compile.

This course is the map I wanted: for each topic, what carries over from C#, what only looks the same, and what has no equivalent.

You write C# comfortably: classes, interfaces, generics, LINQ, async/await, NuGet and the dotnet CLI. You have read some Java but never shipped it. A follow-up course, Spring Boot, Spring Cloud and Reactor for C# developers, builds on this one.

By the end of this course, I will be able to

Section titled “By the end of this course, I will be able to”
  • install a JDK, run Java code and build a project with Maven or Gradle;
  • predict where Java’s value semantics, equality and numbers differ from C#;
  • model data with classes, records, enums and sealed interfaces;
  • use generics knowing what type erasure takes away;
  • handle checked exceptions, null and Optional;
  • translate LINQ and delegates into Streams and functional interfaces;
  • write concurrent code with virtual threads instead of async/await;
  • test, package and run a Java application on the JVM.
# Lesson You already know
1 The JDK and build tools the .NET SDK, dotnet run, NuGet, .csproj
2 Types, equality and operators value types, checked, ==, string interpolation
3 Classes, records and enums properties, virtual/override, record, enum
4 Generics and type erasure reified generics, where T : new(), in/out variance
5 Exceptions, null and Optional (coming next) exceptions, using, nullable reference types
6 Lambdas and functional interfaces delegates, Func/Action, events
7 Collections and Streams List<T>, Dictionary, LINQ
8 Pattern matching switch expressions, is patterns, records
9 Concurrency and virtual threads Task, async/await, lock, Parallel
10 Maven and Gradle in depth NuGet, Central Package Management, solutions
11 Testing xUnit, Moq, FluentAssertions
12 The standard library you reach for DateTime, decimal, HttpClient, System.IO
13 The JVM at run time the CLR, GC settings, dotnet-counters, Native AOT
14 Annotations, reflection and modules attributes, source generators, assemblies

Journal — what I tried, what surprised me, what I still need to verify.