public class A
{
public void GoodMorning()
{
// code;
}
}
public class B()
{
A objA = new A();
objA.GoodMorning();
}
Second method is you can create the method using 'static' so that you dont need to create an object for the class. You can directly call the function like this:
public class B()
{
A.GoodMorning();
}
Restrictions on methods having static are:
a) If you wish to use a variable in side the static method, which is declared outside the static method ie, within class; you must declare that variable as static. Otherwise it will not intake that variable inside the static method.
.jpg)
No comments:
Post a Comment