Why did the Java designer restrict the use of non-static variable in static context? -
i know non-static variables cannot referenced static context. want know why java designer made restriction.
i have checked stack overflow, , there many similar questions , answers, want know exact reason.
so non-static variable means object required variable have value. example if have car
class , have non-static variable price
wouldn't make sense price can referenced car.price
. if asked "what price of car?". tell me varies. logical different cars different prices. if make car bmw
price different car honda
. why have static variable? if have true cars tax on them. want know without having car, description of car is. doesn't mean can't changed means same instances of class.
Comments
Post a Comment