I've seen lots of codes have declaration like Class clazz
, where does this originate from ? Is this some kind of convention ? I think 'clazz' is not even an English word , has no meaning at all , how can so many programmers name a wrong name coincidentally ?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
I saw it first at Josh Bloch's puzzlers. But I'm pretty sure it was used much earlier by other developers. Josh Bloch just made it more famous.
Because they cannot use the word they want to use which is 'class'. It is reserved.
It's simply because 'class' is a reserved keyword, hence
Class class
isn't allowed. Therefore you'll seeClass clazz
orClass cls
.It is just a English word replaced(Equavalent) by Keyword Class Keyword, to make people understand that it is a Class. and it is almost to increase the readability of the Code
Nothing big Logic involved in this
Declaration
Class clazz
is popular in Java world, but it may be awkward for newcomers and spellcheckers. I've heard some people saying that it should be avoided according to principle of least astonishment.As it is possible to say that a
Class
object represents a type, I personally prefer to declare such variables asClass type
.Simply put,
class
has class thatclazz
doesn't.