public static void main ()
{
S1.getTotal();
}
static ReturnType methodname (parameters if any)
{
Block of statements;
}
- class Employee
- {
- static String cname;
- String ename;
- static void change()
- {
- cname="HCL";
- }
- public static void main(String...a)
- {
- System.out.println(Employee.cname);
- Employee.change();
- System.out.println(Employee.cname);
- }
- }
- To Compile - javac employee.java
- To Run - java Employee
- Result - null
HCL
void getTotal()
{
Tot= m1+ m2+ m3;
}
ReturnType methodname (parameters if any)
{
Block of statements;
}
- class Employee
- {
- static String cname="HCL";
- String ename;
- void change(String e)
- {
- ename=e;
- Systme.out.println(ename);
- }
- public static void main(String ...a)
- {
- Employee e1=new Employee;
- System.out.println(e1.ename);
- e1.change("EduEye");
- }
- }
- To Compile - javac employee.java
- To Run - java Employee
- Result - null
EduEye
| Copyright ©2016 | All Rights Reserved |
| Design by Uves Khan |