TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Java - Method Concept
Senthilvelan Sambamoorthy
Jul 26
2016
Code
487
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
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