ey dee ey em
ey dee ey em

Reputation: 8603

public ClassName functionName(arguments){...}, what is the name for this kind of structure in Java?

public UserDefinition getTestUser(String userName) {...}

UserDefinition is a class, getTestUser is a function. What does this really mean?

A function that is named getTestUser is part of the class of UserDefinition?

Or I am wrong with that? What is the term for this kind of way writing a function in java?

Btw above function is a method of another class.

Upvotes: 1

Views: 3406

Answers (2)

Pshemo
Pshemo

Reputation: 124225

Based on: https://docs.oracle.com/javase/tutorial/java/javaOO/methods.html

(BTW in OOP functions and procedures are called "methods")

 ┌modifiers
 |             ┌return type
 |             |          ┌method name
 |             |          |              ┌parameter list
 |             |          |              |            ┌exception list           
 |             |          |              |            |           ┌method body
public UserDefinition getTestUser(String userName) [throws ...] {...}
                      \     method signature    /
                       \  (name + parameters)  /

Upvotes: 4

Dmitry K
Dmitry K

Reputation: 1312

UserDefinition is a return type and getTestUser is method name. The total method declaration looks like this:

[accessSpecifier][static][abstract][final][native][synchronized] 
returnType methodName ([paramlist]) [throws exceptionsList]

You should refer to javadocs

Upvotes: 1

Related Questions