public class CashSales { //declare static member field private static int maxUnitsAllowed = 50; //declare method to return maximum number of units allowed public static int GetMaxUnitsAllowed () { Return maxUnitsAllowed; } } The static field can now be accessed by simply doing CashSales.GetMaxUnitsAllowed(). No need to create an instance of the class.
0 comments:
Post a Comment