Okay so I am trying to replicate my own sorting algorithm into java as Arrays are my weakest link, and as they say, practise makes perfect. I have all the logic I need for it, but I am struggling with the coding as I am still relatively new to Java (any good tutorials will be appreciated).
1) So the first thing I am trying to do is create a user inputted array of any length that has integers. I am basing my code around a string list function I made a while ago except the code does not transfer from String to integer.
The line that the IDE does not like most is when I try and convert:
List<String> numList = new ArrayList<String>();
To
List<int> numList = new ArrayList<int>();
This is probably a syntax error that I am just unable to solve
2) I would like to write something that in my mind would work as:
for(int i = 0; i <= numList.size; i++) {
int number1 = numList[i];
int number2 = numList[i + 1];
int sortedArray[];
if (number1 >= number2) {
sortedArray[i] = number2;
numList[i + 1] = number1;
} else {
sortedArray[i] = number1;
numList[i + 1] = number2;
}
}
As you can see the logic and what seems like to me the code, is there however it still does not work and with my limited java knowledge I can not work out why.