I'm trying to make a program that arranges an array to put the odd numbers before the even numbers, this was my attempt, which I'm doing wrong.
Code:
System.out.print("Indique o número de elementos do array: ");
int a = scanner.nextInt();
int [] Numbers = new int [a];
String Numbers_S = "";
for ( int k = 0; k < a; k++ )
{
System.out.print("elemento na posição " + k + " do array: ");
Numbers [k] = scanner.nextInt();
}
for ( int i = 0; i < a; i++ )
{
if ( Numbers [i] % 2 != 0 )
{
Numbers_S += String.valueOf(Numbers [i]);
}
if ( Numbers [i] % 2 == 0 )
{
Numbers_S += String.valueOf(Numbers [i]);
}
}
for ( int n = 0; n < a; n++ )
{
Numbers [n] = Character.getNumericValue(Numbers_S.charAt(n));
}
String New_Numbers = Arrays.toString(Numbers);
System.out.println(New_Numbers);