Last change
on this file was 800, checked in by wouter, 6 months ago |
converted javax.annotation to org.eclipse.jdt.annotation because javax is deprecated and no maven substitute available.
|
File size:
769 bytes
|
Line | |
---|
1 | package testcode;
|
---|
2 |
|
---|
3 | import org.eclipse.jdt.annotation.NonNull;
|
---|
4 |
|
---|
5 | class MySimpleClass {
|
---|
6 | public @NonNull Integer compute() {
|
---|
7 | return 42;
|
---|
8 | }
|
---|
9 | }
|
---|
10 |
|
---|
11 | interface MyInterface {
|
---|
12 | @NonNull
|
---|
13 | Object getValue();
|
---|
14 |
|
---|
15 | @NonNull
|
---|
16 | Object getPlus();
|
---|
17 | }
|
---|
18 |
|
---|
19 | class MyImpl implements MyInterface {
|
---|
20 |
|
---|
21 | @Override
|
---|
22 | @NonNull
|
---|
23 | public Object getValue() {
|
---|
24 | return "1";
|
---|
25 | }
|
---|
26 |
|
---|
27 | @Override
|
---|
28 | @NonNull
|
---|
29 | public Object getPlus() {
|
---|
30 | return "2" + getValue();
|
---|
31 | }
|
---|
32 |
|
---|
33 | }
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Tests interface and instantiation of it
|
---|
37 | */
|
---|
38 | public class Interfacing {
|
---|
39 |
|
---|
40 | /**
|
---|
41 | *
|
---|
42 | * @param args the arguments of the call.
|
---|
43 | */
|
---|
44 | static public void main(String[] args) {
|
---|
45 | System.out.println(new MySimpleClass().compute());
|
---|
46 | System.out.println(new MyImpl().getValue().toString());
|
---|
47 | System.out.println(new MyImpl().getPlus().toString());
|
---|
48 | }
|
---|
49 |
|
---|
50 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.