salesforce knowledge consolidation

salesforce in Apex language similar to Java

Apex There are several commonly used in data types:

Common basic data types: Integer, String, Boolean, Double, Long, ID, Decimal

Date Time Type: Date, Time, Datetime

Other: Object

In these basic data types, the initial values ​​are null

(A) basic data types

  1.Integer

    32 does not include a decimal point. Minimum integer is 2,147,483,648, a maximum of 2,147,483,647. E.g:

      Integer i = 1;

  2.String

    Enclosed by a single quote character set up, there is no limit on the number of characters, HTML tags can be used, all the strings are also used escape character, with the Java. When used in the string comparison operators SOQL in a case-insensitive.

      String str = 'Hello World';

  3.Boolean

    True or false must be assigned at initialization, otherwise null

  4.Double

    64 contains a decimal point.

  5.Long

    64 does not include a decimal integer in the range -2 ^ 63-2 ^ 63-1. Type Integer can directly convert a Long, Long type without exceeding the range () method to transfer through an Integer intValue.

      Long l = 2147483648L;

  6.ID

    Lightning Platform valid record identifier 18 characters. If the setting is 15, Apex convert the value to 18. Invalid ID anomalies occur at run time.

     ID id = '00300000003T2PGAA0';

  7.Decimal

    Currency field is automatically assigned a Decimal type, similar to Java in the float.

     Decimal d = -3.14;

(B) the date and time type

  1.Date

    It represents the value of a specific date, does not contain information relevant time. Date value can be returned from date plus or minus Integer value.

  2.Time

    It represents the value of a specific time. Time value must always use the system to create a static method.

  3.DateTime

    Datetime type declaration of a target date and time, consists of two parts: the date and time. Datetime no constructor initializes only if instantiated by the static method.

(C) Other types

  1.Object

    Apex support any data type. All Apex data types inherit from Object. More specifically, the object may be represented cast data types for data type basis. E.g:

      Object obj = 10;
      Integer i = (Integer)obj;

 

Guess you like

Origin www.cnblogs.com/unique-zh/p/10945139.html