I'm trying to put the lowest five numbers from one array (they are array objects) into an array by themselves. Here's my code, this is after pulling the array objects into their own array and sorting that array in ascending order. From there I'm trying to keep the lowest 5 items in the array. If there's 5 or more scores I figured slicing the array to keep the first 5 would be the easiest method, if there's less than 5, just copy from one array to the other.
if(scoreID > 5){
int lowestScores = scoreArray.slice(0,6);
}
else {
for(int i=0;i<scoreID;i++) {
int[] lowestScores = new int[scoreID];
lowestScores[i] = scoreArray[i];}
}
scoreID is just a place holder for the number of scores that the primary array is stored.
The error I'm getting is...
Golfer.java:194: error: cannot find symbol
int lowestScores = scoreArray.slice(0,6);
^
symbol: method slice(int,int)
location: variable scoreArray of type int[]
1 error
int[] lowestScores = scoreArray.slice(0,6);int[]to anintvariable.slice()method in Java unless you implemented it yourself.slice()I don't think he can use a.after his scoreArray to use the method. Maybe could be something likeslice(scoreArray, 0, 6)scoreArray.slice()he would have to actually modify theArraysclass in thejava.utilpackage.