As other answers have stated, labels are a seldom used part of the Java language.
But in your case some other things should be considered:
The labels are quite "generic" and are in fact line numbers: L1
, L2
, ...
The labels are not used in the code.
You are studying material for a certification.
This means, that the L1
, L2
labels are simply line numbers. I assume, that the text explaining the code refers to that line numbers. In the same way some books and papers enumerate all mathematical terms just for referencing them in the text or to make citations easier.