I am practicing salesforce and stuck with an error. Can someone help me out?
Error:
Incompatible key type Set for Map at line 23 column 6
Apex Class:
public class mapapex {
public map<string,string> mst;
public list<string> lst {get;set;}
public set<string> str {get;set;}
public set<string> mod {get;set;}
public list<string> s{get;set;};
public mapapex(){
mst= new map<string,string>();
mst.put('India','rupee');
mst.put('USA','Doller');
mst.put('Japan','yen');
}
public pagereference showkey(){
str=mst.keyset();
return null;
}
public pagereference showvalue(){
lst=mst.values();
return null;
}
public pagereference showmod(){
s = mst.get(mod);
return null;
}
}
VF Page:
<apex:page controller="mapapex" >
<apex:form >
<apex:pageBlock >
<apex:commandButton value="showkeys" action="{!showkey}" rerender="one"/>
<apex:dataList id="one" value="{!str}" var="a"> {!a} </apex:dataList>
<apex:commandButton value="showvalue" action="{!showvalue}" rerender="two"/>
<apex:dataList id="two" value="{!lst}" var="b"> {!b} </apex:dataList>
<apex:outputlabel> Enter the value for key- India </apex:outputlable>
<apex:inputText value="{!mod}"/>
<apex:outputlabel> Value for key India is {!s}</apex:outputlable>
</apex:pageBlock>
</apex:form>
</apex:page>