Welcome
This blog contains only articles written in English. You can want read all articles (English
and Italian), or only articles written in Italian by clicking on the following buttons.
protected modifier is a rarely-used access specifier. It is applicable
to variables, methods and constructors, but not to Java types (classes, interfaces,
enumerations, annotations and records), unless they are nested in other types. In this
post, we will avoid talking about nested types and we will focus on this modifier
referring mainly to class members (variables and methods) to make the discussion
simpler. In particular, we will make some important observations regarding protected,
which is often used without the necessary awareness. In addition, we will also digress
on the Singleton pattern to add extensibility to it.
String class in a more profitable and
easier way. This feature allows strings to be defined on multiple lines using a new
syntax. The formatting of multiline strings is more natural than in the past: it will no
longer be necessary to use string concatenations, escape characters such as
\n, and complex management of quotes and spaces. In this way the verbosity
of the code decreases, and readability and ease of writing is improved. In Java 13 and
Java 14, text blocks could be used as feature preview
. Starting with Java 15 they have become a standard feature of the language.
instanceof operator is available as a feature
preview. This will radically change the way we use this operator.
switch expressions and text blocks, a new type of approach has been
introduced for the launch of new features, using the so-called feature preview process. In practice, a new feature is
introduced in order to be usable as a preview for experimental purposes. In this way,
developers can test it, give feedback to Oracle, which in turn can improve it in future
versions.
var. Despite the
complicated name, it is actually quite a simple feature to use. However, several
observations need to be made to see the impact that the introduction of the word
var has on other pre-existing characteristics.
\u0069\u006E\u0074 \u0069 \u003D \u0038\u003B System.out.println(i);
8?// The file will be created inside the C:\users\claudio folder