1.问题: 在dealloc方法中使用[self.xxx release]和[xxx release]的区别? 用Xcode的Analyze分析我的Project,会列出一堆如下的提示:Incorrect decrement of the reference count of an object that is not owned at this point by the caller 仔细看了下代码,都是在dealloc方法中使用了[self.xxx release]这样的语句引起的,把…
测试代码: #encoding:utf-8 class Parent(object): x=1 #x是Parent类的属性(字段) ls=[1,2] #ls是一个列表,也是Parent类的属性(字段) class Child1(Parent): y=2 class Child2(Parent): pass if __name__=='__main__': '''对于类属性:子类与父类的关系是,如果子类重写了继承的值就用子类自己的属性值,否则就用父类的属性值''' print Parent.x,C…
首先看个例子: package zm.demo; public class Demo { private int Id;//成员变量(字段).实例变量(表示该Id变量既属于成员变量又属于实例变量) private String name;//成员变量(字段).实例变量 public int age;//成员变量(字段).实例变量(这里用来举例子,在实际中一般都会设置为private) public static final String mood = "开心";//成员变量(公共字段)…
在Java语言中,所有的变量在使用前必须声明.声明变量的基本格式如下: type identifier [ = value][, identifier [= value] ...] ; 格式说明:type为Java数据类型.identifier是变量名.可以使用逗号隔开来声明多个同类型变量.以下列出了一些变量的声明实例.注意有些包含了初始化过程: int a, b, c; // 声明三个int型整数:a. b.cint d = 3, e = 4, f =…