This shows you the differences between two versions of the page.
basics:ex7 [2007/02/25 17:04] bdefrain |
basics:ex7 [2021/02/05 13:49] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== The Basics: Exercise 7 ====== | ||
- | From the aspect '' | ||
- | |||
- | <note tip> | ||
- | Employ the form '' | ||
- | </ | ||
- | |||
- | This will raise a compiler error since '' | ||
- | |||
- | First, declare a public field '' | ||
- | |||
- | <note tip> | ||
- | The inter-type declaration of members (fields or methods) has the same syntax as the ordinary declarations of members, but the method or field name must be prefixed by name of the receiving class and a dot ('' | ||
- | </ | ||
- | |||
- | Next, add a method '' | ||
- | |||
- | <code aspectj> | ||
- | java.util.Arrays.asList(name, | ||
- | </ | ||
- | |||
- | The declaration of this method should resolve the previous compiler error. To test the new code, add a new class '' | ||
- | |||
- | <code aspectj> | ||
- | public class ApplicationTest { | ||
- | public static void main(String[] arg) { | ||
- | Application t = new Application(); | ||
- | t.name = " | ||
- | for(String s: t) | ||
- | System.out.println(s); | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | To start this new '' | ||
- | |||
- | ---- | ||
- | |||
- | Continue with the [[invariants: |