-
Notifications
You must be signed in to change notification settings - Fork 2
API naming conventions
Brian S. O'Neill edited this page Sep 18, 2024
·
3 revisions
Many of the method names end in an underscore character. This notation is only used to prevent conflicts with Java reserved words, and it doesn't indicate that the method is somehow special or advanced. Some examples:
public_
new_
this_
goto_
If an alternative name can be conceived of which is simple and conveys the same feature, then that's generally preferred. Examples:
-
extend
— doesn't conflict withextends
-
implement
— doesn't conflict withimplements
-
instanceOf
— doesn't conflict withinstanceof
As of Java 10, var
can be used for type inference, but it's not defined as a reserved word. For this reason, the method for creating new local variables is named var
and there's no conflict.