Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Java - Method Concept
WhatsApp
Senthilvelan Sambamoorthy
Jul 26
2016
530
0
0
class
test2
{
double
b,h,a;
void
area() // area is method name
{
a = (
0.5
*b*h);
System.out.println(
"Area of Triangle is : "
+a);
}
public
static
void
main(String arg[])
{
test2 t1 =
new
test2();
test2 t2 =
new
test2();
test2 t3 =
new
test2();
System.out.println(
"\n"
);
t1.b =
10
; t1.h =
20
;
System.out.println(
"Triangle-1"
);
t1.area();
System.out.println(
"\n"
);
t2.b =
20
; t2.h =
500
;
System.out.println(
"Triangle-2"
);
t2.area();
System.out.println(
"\n"
);
t3.b =
50
; t3.h =
100
;
System.out.println(
"Triangle-3"
);
t3.area();
}
}
method
Java
Up Next
Java - Method Concept