-
Sort String
why the output of this program is character:
import java.util.*;
public class array {
public static void main(String[] args) {
String[] strArray = new String[] {"z", "a", "C"};
Arrays.sort(strArray, String.CASE_INSENSITIVE_ORDER);
System.out.println(strArray);
}
}
output is:[Ljava.lang.String;@1a46e30:confused:
-
You're getting the toString() representation of an array. to display an array, either loop through it with System.out.println calls within the loop, or use Code:
System.out.println(java.util.Arrays.toString(strArray));
-
ok sir. got it. thank you so much.
but is it natural that the output will have this symbols [string here]?
example. output: [kier,kyle] instead of kier,kyle.
-
How about using a loop to iterate through the array while printing.
-
hi, can you help how? @dswastik:)
-
Code:
for(int x=0;x<strArray.length;x++){
System.out.println(strArray[x]);
}