Languages
[Edit]
EN

Java - methods naming convention, ideas and examples

3 points
Created by:
Bartek
1173

Methods in java should be named as verb.

Method names examples in java:

  • set
  • get
  • is (isDone)
  • read
  • write
  • execute
  • make
  • run
  • call
  • give
  • calculate
  • send
  • find
  • add
  • subtract
  • invoke
  • select
  • delete
  • insert
  • update
  • move
  • go
  • cancel
  • do
  • append
  • pay
  • look (look for somethin
  • count
  • flush
  • register
  • unregister
  • deregister
  • put
  • change
  • connect
  • disconnect
  • parse
  • reset
  • build
  • clear
  • contains
  • check
  • serialize
  • deserialize
  • replace
  • equals
  • end
  • endsWith
  • startsWith
  • compare
  • convert
  • exchange
  • revert
  • contains
  • concatenate
  • toLowerCase
  • toUpperCase
  • split
  • match
  • isEmpty
  • indexOf
  • offset
  • split
  • notify
  • wait
  • determine
  • designate
  • addAll
  • iterate
  • trim
  • reduce
  • cut
  • restrict
  • limit
  • confirm
  • fix
  • acknowledge
  • install
  • focus
  • setUp
  • repair
  • attach
  • reset
  • adapt
  • bind
  • mark
  • record
  • enroll
  • reject
  • peak
  • see
  • quit
  • display
  • create
  • collect

Usually used in scripting:

  • kill
  • start
  • stop
  • restart
  • relaunch
  • keep it alive

Other useful example:

  • giveDirection
  • calculateDistance
  • makeSomething
  • append (StringBuilder, Builders in general)
  • run (Runnable)
  • get, set (java pojos)
  • isDone (java boolean)
  • isDetected
  • toFixedPrecisionIfNotNull

Also take a look at post with java class, utils, interface naming convention and examples here:

Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.