Benefits of Java static method

--Can be used without instantiation. --Since it is a method shared within the class, it can be accessed from other methods.


class TestClass {

    private TestClass(){
    }

    //static method
    public static void printlnHelloWorld() {
        System.out.println("Hello World!");
    }
}

Use of static methods


public class HelloWorld {
    public static void main(String[] args) {
        TestClass.printlnHelloWorld(); //No instantiation required
    }
}

Recommended Posts

Benefits of Java static method
Method name of static factory method learned from Java 8
Java method
java (method)
Java static
Java method
[Java] method
[Java] method
Implementation of clone method for Java Record
Java8 method reference
[Java] forEach method
java8 method reference
[Java] Random method
[Java] Overview of Java
[Java] split method
[Java] Handling of JavaBeans in the method chain
[Java] Dynamic method call by reflection of enum (enum)
The order of Java method modifiers is fixed
Expired collection of java
Predicted Features of Java
[Java] Significance of serialVersionUID
JAVA DB connection method
Java learning 2 (learning calculation method)
NIO.2 review of java
Review of java Shilber
About Java method binding
[Java ~ Method ~] Study memo (5)
java --Unification of comments
About method splitting (Java)
Studying Java 8 (see method)
Java static [Personal summary]
History of Java annotation
static factory method part 1
Java programming (class method)
definition of ruby method
Features of Static variables
NIO review of java
[Java] Basic method notes
[Java] Three features of Java
Summary of Java support 2018
[Java] How to use compareTo method of Date class
[Java] Meaning of Public static void main (String [] args)
Include image in jar file with java static method
Why implement with a singleton instead of a static method
Summary of file reading method for each Java file format
Setting method to link Java of Eclipse and Github / September 2017
About an instance of java
[Java] New Thread generation method (2)
[Java] Mirage-Basic usage of SQL
A quick explanation of the five types of static in Java
[Java] Beginner's understanding of Servlet-②
[Java] Practice of exception handling [Exception]
Practice of binary search method
[Java11] Stream Summary -Advantages of Stream-
Basics of character operation (java)
[Java] Stack area and static area
Java GC method determination conditions
[Java] Comparison method of character strings and comparison method using regular expressions
[Java] Creation of original annotation
(Small story) Numerical value → simple conversion method of alphabet (Java)
4th day of java learning