Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
JAVA Learning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIGNESH VIJAYAKUMAR
JAVA Learning
Commits
1105d8df
Commit
1105d8df
authored
9 months ago
by
VIGNESH VIJAYAKUMAR
Browse files
Options
Downloads
Patches
Plain Diff
Methods
parent
5efe4210
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Core Java/Methods.java
+37
-0
37 additions, 0 deletions
Core Java/Methods.java
with
37 additions
and
0 deletions
Core Java/Methods.java
0 → 100644
+
37
−
0
View file @
1105d8df
public
class
Methods
{
public
static
void
main
(
String
[]
args
){
//System.out.println("Check statement.");
int
status
=
myMethod
(
"Jhon"
,
25
);
if
(
status
==
1
){
System
.
out
.
println
(
"Printed Succesfully..~!"
);
}
System
.
out
.
println
(
addNums
(
7
,
8
));
System
.
out
.
println
(
addNums
(
3.14
,
4.67
));
System
.
out
.
println
(
"Result of recursion add :: "
+
recursionAdd
(
10
));
}
//if we declare a method with static which means it represent to class not for object
static
int
myMethod
(
String
name
,
int
age
){
//System.out.println("This is print from a method which is called..!");
System
.
out
.
println
(
"Mr."
+
name
+
" is "
+
age
+
" years old."
);
return
1
;
}
//Method overloading
static
int
addNums
(
int
num1
,
int
num2
){
return
num1
+
num2
;
}
static
double
addNums
(
double
num1
,
double
num2
){
return
num1
+
num2
;
}
//Recursion
static
int
recursionAdd
(
int
num
){
if
(
num
>
0
){
//num is refer as a halting condition
return
num
+
recursionAdd
(
num
-
1
);
}
else
{
return
0
;
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment