Java

Java - Static Variable

Java - Static Variable
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(); 
} 
}
Senthilvelan Sambamoorthy

Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.