Foo bar = new Foo();
if(bar instanceof Foo){
... // it's true
}
I was just wondering why we don't use camelcase notation (instanceOf
) instead of how it is (instanceof
).
CamelCase is a way to separate the words in a phrase by making the first letter of each word capitalized and not using spaces. It is commonly used in web URLs, programming and computer naming conventions. It is named after camels because the capital letters resemble the humps on a camel's back.
Java instanceof Operator The instanceof operator in Java is used to check whether an object is an instance of a particular class or not. objectName instanceOf className; Here, if objectName is an instance of className , the operator returns true . Otherwise, it returns false .
instanceof is a binary operator we use to test if an object is of a given type. The result of the operation is either true or false. It's also known as a type comparison operator because it compares the instance with the type. Before casting an unknown object, the instanceof check should always be used.
The name refers to the internal capital letters, which resemble the humps on a camel's back. For example, ComputerHope, FedEx, and WordPerfect are all examples of CamelCase. With computer programming, CamelCase is often used as a naming convention for variables, arrays, and other elements.
instanceof
is an operator and a reserved word, not a method or variable. Camel case is used in Java for method names and variable names.
because instanceof
is an operator, Camel casing
is meant for methods and variables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With