Showing posts with label Program to Demonstrate usage of set in Apex. Show all posts
Showing posts with label Program to Demonstrate usage of set in Apex. Show all posts

Sunday, 9 July 2017

Program to Demonstrate usage of set in Apex

Program to Demonstrate usage of set in Apex

write an apex class to demonstrate set

public class set example 
                { 
                  Public set<string> names {get; set;}
                  Public example ()
                  { 
                   names = new set <string> ();
                   names. add (‘one’);
                   names. add (‘two’); 
                   names. add (‘sam’); 
                   names. add (‘one’);
                   names. add(‘one’); 
                             }
                      } 

Visual force page: 

     <apex: page controllers = “set Example”>   
     <apex: page block>
     <apex: page block table value = “{! Names}” var = ‘a’>
     <apex: column value = “{! a}”/>
     </apex: page block table> 
     </apex: page block> 

     </apex: page>