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
Bounty
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 Static Variable Demo
WhatsApp
Senthilvelan Sambamoorthy
Aug 21
2016
620
0
0
ssvStatic.rar
// static variable demonstration
class
bill
{
String onam;
// onam is instance variable
String hnam;
// hnam is instance variable
int
htax;
// htax is instance variable
static
int
wtax=
300
;
// wtax is static variable
bill(String onam,String hnam,
int
htax)
{
this
.onam = onam;
this
.hnam = hnam;
this
.htax = htax;
}
void
one()
{
System.out.println(
"\nHouse Tax : "
+htax);
}
void
two()
{
System.out.println(
"\nWater Tax : "
+wtax);
}
void
three()
{
int
ttax;
ttax = htax + wtax;
System.out.println(
"\nTotal Tax : "
+ttax);
}
}
class
ssvStatic
{
public
static
void
main(String arg[])
{
bill b =
new
bill(
"ssv"
,
"D69A"
,
1000
);
b.one();
b.two();
b.three();
}
}
Java
Static Variable Demo
Up Next
Java Static Variable Demo