File tree Expand file tree Collapse file tree 2 files changed +31
-8
lines changed Expand file tree Collapse file tree 2 files changed +31
-8
lines changed Original file line number Diff line number Diff line change
1
+ import java .util .Arrays ;
2
+
3
+ /**
4
+ * Demonstrates command-line arguments.
5
+ */
6
+ public class Max {
7
+
8
+ public static void main (String [] args ) {
9
+ System .out .println (Arrays .toString (args ));
10
+
11
+ int max = Integer .MIN_VALUE ;
12
+ for (String arg : args ) {
13
+ int value = Integer .parseInt (arg );
14
+ if (value > max ) {
15
+ max = value ;
16
+ }
17
+ }
18
+ }
19
+ }
Original file line number Diff line number Diff line change @@ -28,13 +28,6 @@ public static void main(String[] args) {
28
28
}
29
29
System .out .println ();
30
30
31
- String fruit = "banana" ;
32
-
33
- for (int i = 0 ; i < fruit .length (); i ++) {
34
- char letter = fruit .charAt (i );
35
- System .out .println (letter );
36
- }
37
-
38
31
String name1 = "Alan Turing" ;
39
32
String name2 = "Ada Lovelace" ;
40
33
if (name1 .equals (name2 )) {
@@ -50,6 +43,17 @@ public static void main(String[] args) {
50
43
System .out .println ("name2 comes before name1." );
51
44
}
52
45
53
- System .out .println (reverse (name1 ));
46
+ String fruit = "banana" ;
47
+
48
+ for (int i = 0 ; i < fruit .length (); i ++) {
49
+ char letter = fruit .charAt (i );
50
+ System .out .println (letter );
51
+ }
52
+
53
+ for (char letter : fruit .toCharArray ()) {
54
+ System .out .println (letter );
55
+ }
56
+
57
+ System .out .println (reverse (fruit ));
54
58
}
55
59
}
You can’t perform that action at this time.
0 commit comments