/**
* HOMEWORK14
*
* @Description: This program finds the string array string[] arr = {"Welcome", "China", "HI",
* "Congratulation", "great"} in the length of the element, and print out the output.
* STRINGDEMO01
*
* @author
*
* Email: [Email protected] April 18, 2017 6:33:59
*
*/
public class StringDemo01 {
public static void Main (string[] args) {
String[] arr = {"Welcome", "China", "HI", "congratulation", "great"};
System.out.print ("The original string array is: \ t");
for (String X:arr) {
System.out.print (x + "");
}
String str = arr[0];
for (int i = 0; i < arr.length-1; i++) {
if (Arr[i].length () < Arr[i + 1].length ()) {
str = arr[i + 1];
}
}
System.out.println ("\ n the element with the largest length of the array is:" + str);
}
}
This procedure finds the largest element in the string array string[] arr = {"Welcome", "China", "HI", "congratulation", "great"}, and prints the output.