java (split source file)

Original source file

public class Calc {
    public static void main(String[] args) {
        int a = 10; int b = 2;
        int total = tasu(a, b);
        int delta = hiku(a, b);
		System.out.println("When added" + total + ", Pull" + delta);
	}
    public static int tasu(int a, int b) {
	    return (a + b);
	}
	public static int hiku(int a, int b) {
	    return (a - b);
	}
}

Divided into multiple classes

Split files with main (), tase (), haiku ()

public class Calc {
    public static void main(String[] args) {
        int a = 10; int b = 2;
        int total = CalcLogic.tasu(a, b);
        int delta = CalcLogic.hiku(a, b);
		System.out.println("When added" + total + ", Pull" + delta);
	}
}

Will not load unless CalcLogic. is added

public class CalcLogic {
    public static int tasu(int a, int b) {
	    return (a + b);
	}
	public static int hiku(int a, int b) {
	    return (a - b);
	}
}

Move tase (), haiku ()

Recommended Posts

java (split source file)
java file creation
Split string (Java)
[Java] split method
[Java] File system operation
Read Java Property file
Comments in Java source
Eval Java source from Java
java core: chopped core file
Read Java HashMap source
[Java] Create a temporary file
[Java] Tips for writing source
[Java] [Android] Read ini file
Read Java properties file in C #
Upload a file using Java HttpURLConnection
Run a batch file from Java
Unzip the zip file in Java
Log output to file in Java
Java
Java source code reading java.lang.Math class
EXCEL file update sample with JAVA
About file copy processing in Java
Java
Basic structure of Java source code
Generate source code from JAR file with JD-GUI of Java Decompiler project
[Java] How to use the File class
[JAWS-UG CLI] CodeBuild: # 1 Creating Source Code (Java)
What is the best file reading (Java)
Why does Java call a file a class?
Read xlsx file in Java with Selenium
[Java] Flow from source code to execution
Java (exception handling, threading, collection, file IO)
Split a string with ". (Dot)" in Java
Java: Place the ResourceBundle properties file anywhere
Sample to unzip gz file in Java
[Java8] Search the directory and get the file
How to split Spring Boot message file