Java: ordenar la matriz de entrada del usuario al regresar
¿Cómo puedo ordenar lo siguiente?
System.out.println("Title: " + titleArray[x].getBook());
Esta línea obtiene sus datos de un Título ingresado por el usuario. Si lo intento
System.out.println("Title: " + Arrays.sort(titleArray[x].getBook()));
Recibo el siguiente error:
LibraryBookSort.java:66: error: no suitable method found for sort(String)
System.out.println("Title: " + Arrays.sort(titleArray[x].getBook()));
^
method Arrays.<T#1>sort(T#1[],int,int,Comparator<? super T#1>) is not applicable
(cannot instantiate from arguments because actual and formal argument lists differ in length)
method Arrays.<T#2>sort(T#2[],Comparator<? super T#2>) is not applicable
(cannot instantiate from arguments because actual and formal argument lists differ in length)
method Arrays.sort(Object[],int,int) is not applicable
(actual and formal argument lists differ in length)
method Arrays.sort(Object[]) is not applicable
(actual argument String cannot be converted to Object[] by method invocation conversion)
method Arrays.sort(double[],int,int) is not applicable
(actual and formal argument lists differ in length)
method Arrays.sort(double[]) is not applicable
(actual argument String cannot be converted to double[] by method invocation conversion)
method Arrays.sort(float[],int,int) is not applicable
(actual and formal argument lists differ in length)
method Arrays.sort(float[]) is not applicable
(actual argument String cannot be converted to float[] by method invocation conversion)
method Arrays.sort(byte[],int,int) is not applicable
(actual and formal argument lists differ in length)
method Arrays.sort(byte[]) is not applicable
(actual argument String cannot be converted to byte[] by method invocation conversion)
method Arrays.sort(char[],int,int) is not applicable
(actual and formal argument lists differ in length)
method Arrays.sort(char[]) is not applicable
(actual argument String cannot be converted to char[] by method invocation conversion)
method Arrays.sort(short[],int,int) is not applicable
(actual and formal argument lists differ in length)
method Arrays.sort(short[]) is not applicable
(actual argument String cannot be converted to short[] by method invocation conversion)
method Arrays.sort(long[],int,int) is not applicable
(actual and formal argument lists differ in length)
method Arrays.sort(long[]) is not applicable
(actual argument String cannot be converted to long[] by method invocation conversion)
method Arrays.sort(int[],int,int) is not applicable
(actual and formal argument lists differ in length)
method Arrays.sort(int[]) is not applicable
(actual argument String cannot be converted to int[] by method invocation conversion)
where T#1,T#2 are type-variables:
T#1 extends Object declared in method <T#1>sort(T#1[],int,int,Comparator<? super T#1>)
T#2 extends Object declared in method <T#2>sort(T#2[],Comparator<? super T#2>)
1 error
¿Asumo que esto se debe a que el constructor no permite la clasificación al regresar? Java.util.Arrays; También se importa.
EDITAR: después de intentar String sortedTitles [] = titleArray [x] .getBook (); fuera del Sysout para establecer una nueva cadena [], recibió el siguiente error ...
LibraryBookSort.java:63: error: incompatible types
String sortedTitles[] = titleArray[x].getBook();
^
required: String[]
found: String
1 error
¿Cómo puedo ordenar la matriz devuelta?