KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ConstantTypes


1 /* ConstantTypes Copyright (C) 1999 Jochen Hoenicke.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; see the file COPYING. If not, write to
15  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
16  *
17  * $Id: ConstantTypes.java,v 1.3 1999/08/19 15:16:59 jochen Exp $
18  */

19
20
21 public class ConstantTypes {
22     static boolean bool = true;
23     static byte b = (byte) 0x80;
24     static char c = '\u0080';
25     static short s = (short)'\u8234';
26     static int i = '\uffff';
27     
28     static void intFunc(int i){}
29     static void shortFunc(short s){}
30     static void charFunc(char c){}
31     static void byteFunc(byte b){}
32
33     static {
34     /* All casts are necessaray */
35     intFunc(25);
36     shortFunc((short) 25);
37     charFunc((char) 25);
38     byteFunc((byte) 25);
39     intFunc('\u0019');
40     shortFunc((short) '\u0019');
41     charFunc('\u0019');
42     byteFunc((byte) '\u0019');
43     intFunc(b);
44     intFunc(c);
45     intFunc(s);
46     intFunc(i);
47     shortFunc(b);
48     shortFunc((short)c);
49     shortFunc(s);
50     shortFunc((short)i);
51     charFunc((char)b);
52     charFunc(c);
53     charFunc((char)s);
54     charFunc((char)i);
55     byteFunc(b);
56     byteFunc((byte)c);
57     byteFunc((byte)s);
58     byteFunc((byte)i);
59     b = 42;
60     c = 42;
61     s = 42;
62     i = 42;
63     i = c;
64     s = b;
65     i = s;
66     c = (char) s;
67     s = (short) c;
68     c = (char) b;
69     b = (byte) c;
70     }
71 }
72
Popular Tags