Food.java
public class Food {
//Move all of the following methods to the Person class
public static String fruits(String fruitsName) {
return fruitName;
}
Call the fruits method of the Food class in Food.java.
Main.java
public class Main {
public static void main(String[] args) {
Food.printData(Food.fruits("apple"));
Food.printData(Food.fruits("straeberry", "Smith"), 65, 1.75, 80.0);
}
}
When calling a method of another class, it is necessary to write the name of the class you want to call before the class name and method name.
Recommended Posts