I have an String array called data which contains :
data: [Solaergy, 3255, Solagy, 3635, Soly, 36235, Solar energy, 54128, Solar energy, 54665, Solar energy, 563265]
Now i want to split data into two arrays title and isbn (of books):
String[] titles = new String[data.length];
String[] isbnS = new String[data.length];
for (int i = 0; i < data.length; i += 2) {
titles[i] = data[i];
isbnS[i] = data[i + 1];
}
System.out.println("titles: " + Arrays.toString(titles));
System.out.println("isbnS: " + Arrays.toString(isbnS));
My problem is that there is a null value after each value in each two arrays:
titles: [Solaergy, null, Solagy, null, Soly, null, Solar energy, null, Solar energy, null, Solar energy, null]
isbnS: [3255, null, 3635, null, 36235, null, 54128, null, 54665, null, 563265, null]
I want to be like this:
titles: [Solaergy, Solagy, Soly, Solar energy, Solar energy, Solar energy]
isbnS: [3255, 3635, 36235, 54128, 54665, 563265]