コンストラクタの使用
https://developer.salesforce.com/docs/atlas.ja-jp.apexcode.meta/apexcode/apex_classes_constructors.htm
メソッドと似ていますが、コンストラクタには明示的な戻り値の型がない
例)
public class TestObject { // The no argument constructor public TestObject() { // more code here } }
これをインスタンス化して使う場合
TestObject myTest = new TestObject();
普通のメソッド使用と同じ
1つのクラスで、同じ名称で型が違うのを呼び出すときとか
例)
public class TestObject2 { private static final Integer DEFAULT_SIZE = 10; Integer size; //Constructor with no arguments public TestObject2() { this(DEFAULT_SIZE); // Using this(...) calls the one argument constructor } // Constructor with one argument public TestObject2(Integer ObjectSize) { size = ObjectSize; } }[コメントが多かった順の記事]
・人の心理の裏をかくホームページ集客術:リピータになってもらうためには(233)
・ホームページ心理学第2弾「メールの書きだしとホームページ運営・集客の関係」(76)
・娘が生まれた(69)
・ゲームと言えば、何を思い出す? (50)
・Microsoftからアクセス (30)
・「目標の立て方」と「努力」と「実行力」(26)
最近のコメント