KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Expressions


1 /* Expressions 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: Expressions.java,v 1.3 1999/08/19 15:16:59 jochen Exp $
18  */

19
20 public class Expressions {
21     double cd;
22     float cf;
23     long cl;
24     int ci;
25     char cc;
26     short cs;
27     byte cb;
28     boolean cz;
29
30     void postIncDecExpressions() {
31     cd++;
32     cf++;
33     cl++;
34     ci++;
35     cs++;
36     cb++;
37     cc++;
38     cd--;
39     cf--;
40     cl--;
41     ci--;
42     cs--;
43     cb--;
44     cc--;
45     float f = 0.0F;
46     double d = 0.0;
47     long l = 0L;
48     f++;
49     f--;
50     d++;
51     d--;
52     l++;
53     l--;
54     }
55     
56
57     void unary() {
58     short s = 25;
59     s = (short) ~s;
60     boolean b = !true;
61     s = b? s: cs;
62     char c= 25;
63     c = b ? c: cc;
64     }
65
66     void shift() {
67     int i = 0;
68     long l =0;
69     l >>= i;
70     l >>= i;
71     i >>= i;
72     l = l << l;
73     l = l << i;
74     l = i << l;
75     l = i << i;
76     i = (int) (l << l);
77     i = (int) (l << i);
78     i = i << l;
79     i = i << i;
80     cl >>= ci;
81     ci <<= ci;
82     cl = cl << cl;
83     cl = cl << ci;
84     cl = ci << cl;
85     cl = ci << ci;
86     ci = (int) (cl << cl);
87     ci = (int) (cl << ci);
88     ci = ci << cl;
89     ci = ci << ci;
90     }
91 }
92
Popular Tags