You need to sign in to do that
Don't have an account?
Andrea Gelsomino
Interface class example
Hi,
I really can't understand this error on this easy Interface exampe, can you please help me to understand how can i use Interface classes on apex code ?
please have a look to the attach.
thanks in advance
Only one independent class/interface is allowed to define in each class. This issue can be solved in two ways:
1. Create different classes for each class and interface.
2. Create and Outer class and keep both the class and interface inside it, as below:
public class OuterClass {
public interface PurchaseOrder {
Double discount();
}
public class test1 implements PurchaseOrder {
public Double discount() {
return .05;
}
}
}
Thanks,
Nirmala
All Answers
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_interfaces.htm
Dnt save Both class in one class.
Create one class like below Then 2nd class like below Let us know if this will help you
Thanks
Amit Chaudhary
Try to save the Interface(i.e., PurchaseOrder) in one class and CustomerPurchaseOrder in another class. You can execute them without errors.
Best Regards,
Deepthi
Only one independent class/interface is allowed to define in each class. This issue can be solved in two ways:
1. Create different classes for each class and interface.
2. Create and Outer class and keep both the class and interface inside it, as below:
public class OuterClass {
public interface PurchaseOrder {
Double discount();
}
public class test1 implements PurchaseOrder {
public Double discount() {
return .05;
}
}
}
Thanks,
Nirmala
Thank you so much guys,
I really like your answers, I prefer this one because i could manage everything inside a "package" class , but i don't undestand how can I reference it, actlually this returns me as an error
OuterClass.test item = new OuterClass.test1()
public class OuterClass {
public interface PurchaseOrder {
Double discount();
}
public class test implements PurchaseOrder {
public Double discount() {
return .05;
}
}
}