OLD | NEW |
1 // jprint.java test program. | 1 // jprint.java test program. |
2 // | 2 // |
3 // Copyright 2004, 2010-2012 Free Software Foundation, Inc. | 3 // Copyright 2004, 2010-2012 Free Software Foundation, Inc. |
4 // | 4 // |
5 // Written by Jeff Johnston <jjohnstn@redhat.com> | 5 // Written by Jeff Johnston <jjohnstn@redhat.com> |
6 // Contributed by Red Hat | 6 // Contributed by Red Hat |
7 // | 7 // |
8 // This file is part of GDB. | 8 // This file is part of GDB. |
9 // | 9 // |
10 // This program is free software; you can redistribute it and/or modify | 10 // This program is free software; you can redistribute it and/or modify |
11 // it under the terms of the GNU General Public License as published by | 11 // it under the terms of the GNU General Public License as published by |
12 // the Free Software Foundation; either version 3 of the License, or | 12 // the Free Software Foundation; either version 3 of the License, or |
13 // (at your option) any later version. | 13 // (at your option) any later version. |
14 // | 14 // |
15 // This program is distributed in the hope that it will be useful, | 15 // This program is distributed in the hope that it will be useful, |
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 // GNU General Public License for more details. | 18 // GNU General Public License for more details. |
19 // | 19 // |
20 // You should have received a copy of the GNU General Public License | 20 // You should have received a copy of the GNU General Public License |
21 // along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 // along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 |
23 import java.util.Properties; | 23 import java.util.Properties; |
24 | 24 |
25 class jvclass { | 25 class jvclass { |
26 public static int k; | 26 public static int k; |
27 static { | 27 static { |
28 k = 77; | 28 k = 77; |
29 } | 29 } |
30 public static void addprint (int x, int y, int z) { | 30 public static int addprint (int x, int y, int z) { |
31 int sum = x + y + z; | 31 int sum = x + y + z; |
32 System.out.println ("sum is " + sum); | 32 System.out.println ("sum is " + sum); |
| 33 return sum; |
33 } | 34 } |
34 | 35 |
35 public int addk (int x) { | 36 public int addk (int x) { |
36 int sum = x + k; | 37 int sum = x + k; |
37 System.out.println ("adding k gives " + sum); | 38 System.out.println ("adding k gives " + sum); |
38 return sum; | 39 return sum; |
39 } | 40 } |
40 } | 41 } |
41 | 42 |
42 public class jprint extends jvclass { | 43 public class jprint extends jvclass { |
43 public static Properties props = new Properties (); | 44 public static Properties props = new Properties (); |
44 public static String hi = "hi maude"; | 45 public static String hi = "hi maude"; |
45 | 46 |
46 public int dothat (int x) { | 47 public int dothat (int x) { |
47 int y = x + 3; | 48 int y = x + 3; |
48 System.out.println ("new value is " + y); | 49 System.out.println ("new value is " + y); |
49 return y + 4; | 50 return y + 4; |
50 } | 51 } |
51 public static void print (int x) { | 52 public static int print (int x) { |
52 System.out.println("x is " + x); | 53 System.out.println("x is " + x); |
| 54 return x; |
53 } | 55 } |
54 public static void print (int x, int y) { | 56 public static int print (int x, int y) { |
55 System.out.println("y is " + y); | 57 System.out.println("y is " + y); |
| 58 return y; |
56 } | 59 } |
57 public static void main(String[] args) { | 60 public static void main(String[] args) { |
58 jprint x = new jprint (); | 61 jprint x = new jprint (); |
59 x.dothat (44); | 62 x.dothat (44); |
60 print (k, 33); | 63 print (k, 33); |
| 64 print (x.addk(0), 33); |
61 } | 65 } |
62 } | 66 } |
63 | 67 |
64 | 68 |
OLD | NEW |