You need to sign in to do that
Don't have an account?
Developer Base
What does this mean in java? (Java fundamentals question!)
Hey whatsup,
what does this mean?
Tools is a class I have a method called findRecordByValue, but WHAT IS THIS????
Can someone give me a link to explanation about what this is? It seems like a java fundamental thing.
what does this mean?
Product2 pro; if ((pro = (Product2)Tools.findRecordByValue(pros, 'Id', rec.Product2Id)) != null) { ... some code here }
Tools is a class I have a method called findRecordByValue, but WHAT IS THIS????
(Product2)Tools.findRecordByValueWhy is (Product2) before the Tools method???
Can someone give me a link to explanation about what this is? It seems like a java fundamental thing.
pro is of data type Product2 and Tools.findRecordByValue is returning some data type.
In order to assign the returned value to pro, we must ensure both are of same type.
Hence, with (Product2) Tools.findRecordByValue we are type-casting the returned value to Product2.
FYR - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_casting.htm
Hope this helps!
All Answers
pro is of data type Product2 and Tools.findRecordByValue is returning some data type.
In order to assign the returned value to pro, we must ensure both are of same type.
Hence, with (Product2) Tools.findRecordByValue we are type-casting the returned value to Product2.
FYR - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_casting.htm
Hope this helps!