The diamond operator (<>) is used in Perl for I/O and in Java for generics.
Perl
The Perl diamond operator is a special case of the stream input operator <FILEHANDLE>
when the filehandle to read from is left void. In such a case, it strives to emulate sed
/awk
behavior by reading from files from the command line, falling back to standard input if there are not files left on the command line.
Java
The Java <>
construct (in formally knows as "the diamond") was introduced in Java SE 7 to make declaring and initializing generic types more brief by automatic type inference during generic class instantiation. You can learn more about this in the Oracle Java Tutorial or the Java Language Specification.
A simple example of the concept is the following. Instead of writing this (before Java 7)
Map<String, List<String>> myMap = new HashMap<String, List<String>>();
Starting in Java 7, you can write the above as:
Map<String, List<String>> myMap = new HashMap<>();
(Note that <>
is NOT an operator in Java, despite what you may hear or see in many places, and despite the name of this tag! The official Oracle sources all bear this out.)