Languageeasy0-2 years

When is var appropriate, and what are text blocks for?

var infers a local's type at compile time — use it when the type is visible on the line (new HashMap<...>()) or irrelevant to the reader; keep the explicit type when a method's return would leave the reader guessing. Text blocks are multi-line strings with indentation stripped, for SQL, JSON and HTML in code and tests.

The lesson behind it →
More on Language