Can I call a method in another class with the same method name but with different cases. For example a method testMethod() is in classA. And itsl is called as ClassA.TestMethod() in ClassB. Will it work?
-
1Welcome to SFSE! Please take the tour and read How to Ask. You will need to edit your question to include more details.– Tushar JadavCommented Apr 22 at 13:07
-
In the same class? no. In another class? almost certainly yes. This is assuming you're working entirely within Apex (no JS/Aura/LWC). Please edit your question to include an example of what you're trying to do. If you're running into any errors, you should copy/paste the entirety of the error verbatim.– Derek FCommented Apr 22 at 13:07
Add a comment
|
1 Answer
Yes, it's possible to call a method in another class with the same method name but different cases. For instance, if you have a method named testMethod() in ClassA, and you call it as ClassA.TestMethod() from ClassB (as long as testMethod() is public), the code should work as expected. However, your IDE might show a warning for case mismatch. But in terms of functionality, it should work fine.
-
1If the IDE knows about Apex (e.g. VS Code), it should be able to resolve the symbols correctly anyways.– sfdcfox ♦Commented Apr 22 at 14:07