Equivalent verbatim operator for java [duplicate]
Does java have an equivalent operator or language construct as the verbatim operator(@) in C#?
No, Java does not have such an operator.
Quick Googling tells me that verbatim operator in C# is apparently just syntactic sugar.
No, there's no equivalent in Java. Java isn't about syntactic sugar, the main focus of Java as a language is to provide only one way to perform or otherwise get a single function, that's why each reserved word in Java has only one function and a lot of syntactic sugar is missing. Just to emphasise, @ is already reserved for annotations.
While the benefits and shortcomings of this can be discussed to eternity, the bottom line is that Java is really sparse in syntactic sugar, in fact only syntactic sugar in Java I can think of is the enhanced for
loop and even then internally JVM knows only of while
loops, anyway.
精彩评论