Skip to content

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 with extends
  • implement — doesn't conflict with implements
  • instanceOf — doesn't conflict with instanceof

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.

Clone this wiki locally