An article released exclusively on October 20, 2017.
package package name;
import package name; //FQCN can be omitted.
To call a method of another class, specify as follows.
name of the class.Method name;
Main.java
public class Main {
public static void main (String args[]) {
System.out.println("This is the Tokaido Shinkansen.");
others.keikyu(); //Specify class
System.out.println("Linear is here!");
System.out.println(linear(new java.util.Scanner(System.in).nextLine()) + "The number of flights was reduced to books!");
}
public static int linear (String afraid) { //Specify the return value and argument type
System.out.println(afraid + "And so on ...");
int howmany = new java.util.Random().nextInt(100);
System.out.println("1 day" + howmany + "It will reduce the number of flights to books!");
return howmany; //Returns a variable
}
}
others.java
public class others {
public static void keikyu () {
System.out.println("Akaden, I'm pulling it out!");
}
}
Recommended Posts