lip stick :
Using the main below, create the methods that will give the String[]
result.
Please write the loop in the main to print the array of a multi spell.
public static void main(String[] args) {
// Create array here
// use your array to create new array here
String[] multispell = Attack(“your array”, “ball”);
Output:
Cast Fire ball!!!
Cast Ice ball!!!
Cast Earth ball!!!
Cast Lightning ball!!!
Cast Wind ball!!
my program:
public class Paper {
public static void main (String args[]) {
String[] kind = new String[5];
String [] multispell = Attack4 ( kind , "ball" );
for (int i = 0 ; i< multispell.length ; i++) {
System.out.println ("Cast " + multispell[i]+ "!!!");
}
}
public static String[] Attack4() {
String [] kind111 = {"Fire", "Ice", "Earth", "Lightning", "Wind"};
return kind111 ;
}
}
Ahmet OZKESEK :
Is this what you are looking for?
public static void main(String[] args) {
String[] kind = new String[] {
"Fire", "Ice", "Earth", "Lightning", "Wind"
};
String[] multispell = Attack(kind, "ball");
for (int i = 0; i < multispell.length; i++) {
System.out.println("Cast " + multispell[i] + "!!!");
}
}
public static String[] Attack(String[] orig, String attach) {
String[] result = new String[orig.length];
for (int i = 0; i < orig.length; i++) {
result[i] = orig[i] + " " + attach;
}
return result;
}
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=394379&siteId=1