• mikun
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hi All,
   I got a doubt regarding this get and set methods . Please check this class.

public with sharing class class2 {
    public string prop1 {
      get { System.debug('ppp get p1'); return prop1; }
      set { System.debug('ppp set p1'); prop1 = value; }
       }
       
       public string prop2;
       public string getprop2(){
        System.debug('ppp get p2');
        return prop2;           
       }
       public void setprop2(string i){
           System.debug('ppp set p2');
           prop2 =i;
       }
 
    public static testMethod void test1(){
        class2 c = new class2();
        System.debug('prop1--'+c.prop1);
        c.prop1 = 'test prop1';
        System.debug('prop2--'+c.prop2);
        c.prop2 = 'test prop2';
    }
}

so when i run this class the get and set of 'prop1' executes but not of 'prop2'. And BTW what is the difference between this two way of writing get and set for a variable.So plz help me understand this.


Thank You,
Mikun

 

  • January 18, 2013
  • Like
  • 0

Hi All,
      I have a visualforce page where i want to show a look up . i have this custom object where there is a field 'serial number' . so on my page i want the look up ll pop up a new window where all serial numbers will be shown row wise. like the standard look up window. Could any one of you please provide me if you have any existing code. or guide me how to accomplish this.I really need help on this.


Thanks a lot.

  • October 12, 2012
  • Like
  • 0
Hi All,
   I got a doubt regarding this get and set methods . Please check this class.

public with sharing class class2 {
    public string prop1 {
      get { System.debug('ppp get p1'); return prop1; }
      set { System.debug('ppp set p1'); prop1 = value; }
       }
       
       public string prop2;
       public string getprop2(){
        System.debug('ppp get p2');
        return prop2;           
       }
       public void setprop2(string i){
           System.debug('ppp set p2');
           prop2 =i;
       }
 
    public static testMethod void test1(){
        class2 c = new class2();
        System.debug('prop1--'+c.prop1);
        c.prop1 = 'test prop1';
        System.debug('prop2--'+c.prop2);
        c.prop2 = 'test prop2';
    }
}

so when i run this class the get and set of 'prop1' executes but not of 'prop2'. And BTW what is the difference between this two way of writing get and set for a variable.So plz help me understand this.


Thank You,
Mikun

 

  • January 18, 2013
  • Like
  • 0