Last change
on this file was 1205, checked in by wouter, 6 weeks ago |
#379 added test showing issue with initializing arrays. Fixed the init issue.
|
File size:
779 bytes
|
Line | |
---|
1 | package testcode;
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * prints default values for various non-initialized fields
|
---|
5 | *
|
---|
6 | */
|
---|
7 | public class DefaultValues {
|
---|
8 | private int x;
|
---|
9 | private boolean b;
|
---|
10 | private String s;
|
---|
11 | private static float y;
|
---|
12 | private static float z = 1f;
|
---|
13 | private double[] arr = new double[10];
|
---|
14 | private Double[] darr = new Double[10];
|
---|
15 | private boolean[] barr = new boolean[10];
|
---|
16 |
|
---|
17 | static public void main(String[] args) {
|
---|
18 | new DefaultValues().test();
|
---|
19 | }
|
---|
20 |
|
---|
21 | private void test() {
|
---|
22 | System.out.println(((Integer) x).toString());
|
---|
23 | System.out.println(((Float) y).toString());
|
---|
24 | System.out.println(((Float) z).toString());
|
---|
25 | System.out.println(((Boolean) b).toString());
|
---|
26 | System.out.println(s == null);
|
---|
27 | System.out.println(arr[2]);
|
---|
28 | System.out.println(darr[2] == null);
|
---|
29 | System.out.println(barr[5]);
|
---|
30 | }
|
---|
31 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.