Test.java Source code

Java tutorial

Introduction

Here is the source code for Test.java

Source

import java.beans.Expression;

public class Test {

    public static void main(String args[]) throws Exception {
        Person person = new Person();
        String arguments[] = { "AAA" };
        Expression expression = new Expression(null, person, "setName", arguments);

        System.out.println("Name: " + person.getName());
        expression.execute();
        System.out.println("Name: " + person.getName());

        System.out.println();
        expression = new Expression(null, person, "getName", null);
        System.out.println("Name: " + person.getName());
        expression.execute();
        System.out.println("getValue: " + expression.getValue());
    }
}

class Person {
    private String name;

    public Person() {
        this("Jane", 23);
    }

    public Person(String name, int age) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}