4 Antworten
Hi Ancy,In Apex you have to first save the class like below with out object definition inside the class to excute the class:Setup --> Apex Class --> New.Public class Person{private String firstName;private String lastName;private Integer age;Public person(String firstName,String lastName,Integer Age){this.firstName=firstName;this.lastName=lastName;this.Age=Age;}Public void printInfo(){System.debug('First Name :'+firstName);System.debug('Last Name :'+lastName);System.debug('Age:'+age);}}========================Then only execute the below two lines in Developer Console:Person P1=new Person('Robert','Chris',30); P1.printInfo();Now Open the Log you can see your output.Don't include the Object Defnition inside the class as like java to run the code.Can you please Let me know if it helps or not!!! If it helps don't forget to mark this as a best answer!!!Thanks,Maharajan.C