Last change
on this file was 1177, checked in by wouter, 7 weeks ago |
#371 add repr method by default, to ensure items print as in java.
|
File size:
766 bytes
|
Line | |
---|
1 | package testcode;
|
---|
2 |
|
---|
3 | import java.util.Arrays;
|
---|
4 |
|
---|
5 | import org.eclipse.jdt.annotation.NonNull;
|
---|
6 |
|
---|
7 | enum SimpleEnum {
|
---|
8 | P, Q, R;
|
---|
9 |
|
---|
10 | public @NonNull String val() {
|
---|
11 | return "$";
|
---|
12 | }
|
---|
13 | }
|
---|
14 |
|
---|
15 | enum MyEnum {
|
---|
16 | A(1), B(2), C(3);
|
---|
17 |
|
---|
18 | private int value;
|
---|
19 |
|
---|
20 | MyEnum(int value) {
|
---|
21 | this.value = value;
|
---|
22 | }
|
---|
23 |
|
---|
24 | public int getValue() {
|
---|
25 | return value;
|
---|
26 | }
|
---|
27 | }
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Test for translation to python.<br>
|
---|
31 | * Extra line for multiline-test.
|
---|
32 | */
|
---|
33 | public class EnumClass {
|
---|
34 |
|
---|
35 | static public void main(String[] args) {
|
---|
36 | System.out.println(SimpleEnum.Q.toString());
|
---|
37 | System.out.println(SimpleEnum.Q.val());
|
---|
38 | System.out.println(MyEnum.A.toString());
|
---|
39 | MyEnum b = MyEnum.valueOf("B");
|
---|
40 | System.out.println(b.toString());
|
---|
41 | System.out.println(b.getValue());
|
---|
42 | System.out.println(Arrays.asList(MyEnum.values()));
|
---|
43 | }
|
---|
44 |
|
---|
45 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.