We know that functions in java are block of code written to perform a specific task. For example if we need to add two numbers multiple times in same code, it would be very tedious to rewrite the same code again and again, so instead we create a function or a method (a function inside a class is called method) in java. So that instead of writing the whole code we can just call that function.

The syntax of a function appears as follow:

<Access specifier>   <returntype>   <name of finction> (parameter){
...body of function
}

Example:

Above is code for function that would print Hello World three times, we can see that at first we mentioned the access specifier then the type of function, as I wrote it in the main class that would contain the main function later in the code, …

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help