Hi,
 
I am working on the Java Annotation lab MutatorAnnotation.java exercises.  I 
have no clue of how the code in red could have any affect to setName method :
 
public class MutatorAnnotation {
    
    private String name;
    private int id;
    
    /**
     *  Constructor
     **/
    public MutatorAnnotation() {
        name = "Java Passion!";
    }
    
    public String getName() {
        return name;
    }
    
    @Mutator(variable = "name")
    public void setName(String name) {
        this.name = name;
    }
 
@Retention(RetentionPolicy.RUNTIME)
public @interface Mutator {                       // annotation definition
    String variable();
}
    
public static void main(String[] args) {
        // TODO code application logic here
        MutatorAnnotation mutAnnot = new MutatorAnnotation();  // code I added
        System.out.println("Name is : "+mutAnnot.getName());
 
Run result:
run:
Name is : Java Passion!
BUILD SUCCESSFUL (total time: 0 seconds)

The result display "Java Passion". In this case the Mutator annotation has no 
impact to the setName method. Then what is the usage of have this method 
annotated by the @Mutator annotation. Would like to see some code how @Mutator 
annotation could apply to practical usage?
 
Thank you!
 
Regards,
Anthony

 
 
 

                                          
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
https://signup.live.com/signup.aspx?id=60969

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to