1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package com.puppycrawl.tools.checkstyle.checks.coding.magicnumber;
16
17
18
19
20
21
22 public class InputMagicNumberDefault1 {
23 public void magicMethod() {
24
25 final int INT_CONST = 101_000;
26 final long LONG_CONST1 = 100_000L;
27 final long LONG_CONST2 = 100l;
28 final float FLOAT_CONST1 = 1.500_0F;
29 final float FLOAT_CONST2 = 1.5f;
30 final double DOUBLE_CONST1 = 1.500_0D;
31 final double DOUBLE_CONST2 = 1.5d;
32 final double DOUBLE_CONST3 = 1.5;
33
34 int int_var1 = 1;
35 int int_var2 = (2);
36 long long_var1 = 0L;
37 long long_var2 = 0l;
38 double double_var1 = 0D;
39 double double_var2 = 0d;
40
41 int[] int_array = new int[2];
42
43 int_var1 = 1 + 2;
44 int_var1 += 1;
45 double_var1 = 1.0 + 2.0;
46
47 for (int i = 0; i < 2; i++);
48
49 if (1 < 2);
50
51 if (1.0 < 2.0);
52
53
54 int int_magic1 = 3_000;
55 double double_magic1 = 1.5_0;
56 int int_magic2 = (3 + 4);
57
58 int_array = new int[3];
59
60 int_magic1 += 3;
61 double_magic1 *= 1.5;
62
63 for (int j = 3; j < 5; j += 3) {
64 int_magic1++;
65 }
66
67 if (int_magic1 < 3) {
68 int_magic1 = int_magic1 + 3;
69 }
70
71 int octalVar0 = 00;
72 int octalVar8 = 010;
73 int octalVar9 = 011;
74
75 long longOctalVar8 = 0_10L;
76 long longOctalVar9 = 011l;
77
78 int hexVar0 = 0x0;
79 int hexVar16 = 0x10;
80 int hexVar17 = 0X011;
81 long longHexVar0 = 0x0L;
82 long longHexVar16 = 0x10L;
83 long longHexVar17 = 0X11l;
84 }
85 }
86
87 interface Blah2Default1
88 {
89 int LOW = 5;
90 int HIGH = 78;
91 }
92
93 class ArrayMagicTestDefault1
94 {
95 private static final int[] NONMAGIC = {3};
96 private int[] magic = {3};
97 private static final int[][] NONMAGIC2 = {{1}, {2}, {3}};
98 }