You need to sign in to do that
Don't have an account?
Enrico dev
Share Map between Outer and inner class
I want to implement the following setup:
-Outer: create and use map
-Inner: Fill values in the map
I' ve tried the above way but the map is not visible in the inner class. How can accomplish this?
Thanks in advantage for any advice.
public class Outer{ public Map<string,string> PackageTransportUnitType { get; set; } public Outer(){ PackageTransportUnitType=new Map<string,string>(); Inner MyInner=new Inner(); system.debug('My Map'+PackageTransportUnitType); } public class Inner{ public Inner(){ //NOT POSSIBLE TO ACCESS PackageTransportUnitType PackageTransportUnitType.put('test','test') } } }I want to share the map "PackageTransportUnitType " between inner and outer class in this way:
-Outer: create and use map
-Inner: Fill values in the map
I' ve tried the above way but the map is not visible in the inner class. How can accomplish this?
Thanks in advantage for any advice.
1. Change the Map to a Static variable so that it can be used anywhere in the context.
2. Or change your structure of class to make the Outer class as virtual class and extend it with your innerclass, then you can use Super.
Use this,