I need a variable that represents an interface. I was wondering if there is a "standard" name for such a variable, like for example the clazz for a Class variable. I was thinking of naming it aInterface, but I don't realy like this name...
Variable named interface
Asked Answered
In general my interface names start with I, like, IMyInterface
. And I use 'i' as prefix for variable name where I need to indicate the variable is interface, like iMyInterfaceVar
. But no such restriction or standard rule.
Just for sake of completeness, here is The Java Code Convention Guide
In the lines of clazz
, you could use interfaze
!
Funny, but I hope Deelazee doesn't take this too seriously. –
Textualism
In general my interface names start with I, like, IMyInterface
. And I use 'i' as prefix for variable name where I need to indicate the variable is interface, like iMyInterfaceVar
. But no such restriction or standard rule.
Just for sake of completeness, here is The Java Code Convention Guide
© 2022 - 2024 — McMap. All rights reserved.
Class clazz = yourObj.getClass()
??? – Babbittryclazz
is just a name of the variable of typejava.lang.Class
. In general, although it is a bad practice people tend to useString string
for declaring aString
variable quickly. The same wayclazz
is used as we cannot useclass
which is a restricted key word in Java. This is generally used when one tries to load classes programatically. – Lumumba