forked from PacktPublishing/Java-Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
22 lines (14 loc) · 665 Bytes
/
Main.java
File metadata and controls
22 lines (14 loc) · 665 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package modern.challenge;
import java.lang.reflect.Method;
import java.util.List;
public class Main {
@SuppressWarnings("unchecked")
public static void main(String[] args) throws ReflectiveOperationException {
Method cultivateMethod = Melon.class.getDeclaredMethod(
"cultivate", String.class, Seed.class, int.class);
Melon instanceMelon = Melon.class.getDeclaredConstructor().newInstance();
List<Melon> cultivatedMelons = (List<Melon>) cultivateMethod.invoke(
instanceMelon, "Gac", new Seed(), 10);
System.out.println(cultivatedMelons);
}
}