Respuesta :
Answer:
Explanation:
The following code was written in Java and performs the exact requirements listed in the question. It has also been tested by the runner code and works perfectly.
public static boolean insert(String[] words, String newWord, int place) {
if (place > words.length) {
return false;
} else {
for (int x = words.length - 1; x >= 0; x--) {
if (place == x) {
words[x] = newWord;
break;
} else {
words[x] = words[x-1];
}
}
return true;
}
}
Methods are group of code segments that are executed when evoked or called.
The insert public static method in Java, where comments are used to explain each line is as follows:
//This defines the method
public static boolean insert(String[] words, String newWord, int place) {
//This returns false, if the place value is less than the word length
if (place > words.length) {
return false;
}
//If otherwise
else {
//This iterates through the characters of the word, in reverse order
for (int i = words.length - 1; i >= 0; i--) {
//This inserts the new word into the array
if (place == i) {
words[i] = newWord;
break;
} else {
words[i] = words[i-1];
}
}
//This returns true
return true;
}
}
Read more about methods at:
https://brainly.com/question/13628934