Welcome - Benvenuto
This blog contains articles in both Italian and English. You can filter the articles by
language 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.
protected
è un specificatore d'accesso utilizzato alquanto
raramente, applicabile a variabili, metodi e costruttori, ma non a tipi Java (classi,
interfacce, enumerazioni, annotazioni e record), a meno che essi non siano innestati in
altri tipi. In questo articolo eviteremo di parlare dei tipi innestati e ci limiteremo a
parlare di tale modificatore riferendoci soprattutto ai membri (variabili e metodi)
delle classi per semplificare il discorso. In particolare faremo alcune osservazioni
importanti riguardo tale modificatore, che è spesso usato senza la necessaria
consapevolezza. Inoltre faremo una digressione anche sul pattern Singleton per
aggiungere ad esso l'estensibilità.
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.
String
in maniera più proficua e più semplice. Tale caratteristica permette
alle stringhe di essere definite su più linee utilizzando una nuova sintassi. La
formattazione delle stringhe multilinea è più naturale rispetto al passato: non sarà più
necessario ricorrere continuamente a concatenazioni di stringhe, a caratteri di escape
come \n
, e ad una complessa gestione delle virgolette e delle spaziature.
In questo modo la verbosità del codice diminuisce, ed è favorita la leggibilità e la
facilità di scrittura. In Java 13 e Java 14, i text block potevano essere utilizzati
come feature preview. A partire da Java 15 sono diventati
a tutti gli effetti una caratteristica standard del linguaggio.
instanceof
operator is available as a feature
preview. This will radically change the way we use this operator.
instanceof
. Questo cambierà radicalmente il modo in cui utilizziamo tale
operatore.
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.
var
. A dispetto del nome complicato, in realtà si tratta di una
caratteristica piuttosto semplice da utilizzare. Tuttavia bisogna fare diverse
osservazioni per vedere l'impatto che ha l'introduzione della parola var
su
altre caratteristiche preesistenti.
\u0069\u006E\u0074 \u0069 \u003D \u0038\u003B System.out.println(i);
8
?// Il file verrà generato all'interno della cartella C:\users\claudio
\u0069\u006E\u0074 \u0069 \u003D \u0038\u003B System.out.println(i);
8
?// The file will be created inside the C:\users\claudio folder