function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kishaloy NandyKishaloy Nandy 

Getting error for constructor

Hi,
I was going through practice session about constructors but my program keeps on failing

I used the code:
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;  
   }
}


and At Execute Anonymous Window Giving:

TestObject2 myObject1 = new TestObject2(42);
TestObject2 myObject2 = new TestObject2();

I am getting an error:

Line: 1, Column: 25
Constructor not defined: [TestObject2].<Constructor>(Integer)

What is wrong here?
Best Answer chosen by Kishaloy Nandy
sfdcMonkey.comsfdcMonkey.com
hi Kishaloy Nandy
your code is fine
make sure your TestObject2 class save Successfully without any error
can you send screenshort of TestObject2 class
Thanks
 

All Answers

sfdcMonkey.comsfdcMonkey.com
hi Kishaloy Nandy
your code is fine
make sure your TestObject2 class save Successfully without any error
can you send screenshort of TestObject2 class
Thanks
 
This was selected as the best answer
Kishaloy NandyKishaloy Nandy
Strange!!! today it got executed without any error.