Apex开发指导–数据类型
1,主数据类型
2,非主数据类型
3,集合类型
4,枚举类型
主数据类型
all primitive data type arguments, such as Integer or String, are passed into methods by value. This fact means that any changes to the arguments exist only within the scope of the method. When the method returns, the changes to the arguments are lost.
所有的主数据类型的参数(例如Integer和string),在传入方法的时候,传入的是值,而不是地址。这个类似于C,语言的传参,有普通的参数和指引型参数。这意味着参数的作用范围只在方法内,当方法结束之后,参数的值就释放了。不会去改变原来传入的值。
所有主数据类型初始化的时候的赋值都为 null,所以在使用的时候最好给初始化一个合适的值。防止出现异常。例如
Date d;
d.addDays(2); —这个就会报null指针异常
14中主数据类型
Blob
Boolean
Date
Datetime
String
Decimal
Double
Integer
Long
Object
ID(这个必须是18位或者15位的id,不然会报执行时异常)
Time
AnyType: valueOf 方法将一个anytype类型的sobject上的字段转化为标准的主数据类型,这种类型用于在追