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) {
2828 }
2929 System .out .println ();
3030
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-
3831 String name1 = "Alan Turing" ;
3932 String name2 = "Ada Lovelace" ;
4033 if (name1 .equals (name2 )) {
@@ -50,6 +43,17 @@ public static void main(String[] args) {
5043 System .out .println ("name2 comes before name1." );
5144 }
5245
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 ));
5458 }
5559}
You can’t perform that action at this time.
0 commit comments