Java與python的面向物件對比
Java |
Python |
public class Employee { |
class Employee: '所有員工的基類' empCount = 0 def __init__(self, name, salary): self.name = name self.salary = salary Employee.empCount += 1 def displayCount(self): print "Total Employee %d" % Employee.empCount def print "Name : ", self.name, ", Salary: ", self.salary empCount靜態變數 __init__構造器 self:this |