java (method)

Method definition

public static void hello() {           //①
   System.out.println("Hello")     //②

① Statement of important matters (method name is hello) ② Processing content

Use of arguments

public static void main(String[] args) {
     System.out.println("Call the method");
     hello("A");
     hello("B");
     hello("C");
     System.out.println("The method call is finished");
}
public static void hello(String name) {  
     System.out.println(name + "Kun, Hello");
}

① Pass A, B, C and call the hello method (2) String variable: Declare name ③ Actual argument: A.B.C Formal argument: name ** Actual display ** A-kun, Hello B-kun, Hello C-kun, Hello

How to pass arguments

If nothing is passed: Method name () When passing one value: Method name (value) When passing multiple values: Method name (value, value, ...) (In case of multiple, use by separating with comma,)

Use of return value

return Return value;

** Notes on return statement ** It also terminates the method. Even if you write a process after the return statement, it will not be executed.

Recommended Posts

Java method
java (method)
Java method
[Java] method
[Java] method
Java8 method reference
[Java] forEach method
java8 method reference
[Java] Random method
[Java] split method
Method
JAVA DB connection method
Java learning 2 (learning calculation method)
Java learning memo (method)
About Java method binding
[Java ~ Method ~] Study memo (5)
About method splitting (Java)
Studying Java 8 (see method)
Java programming (class method)
Java
Java
[Java] Basic method notes
[Java] New Thread generation method (2)
Java GC method determination conditions
Java Silver Study Method Memo
Create a java method [Memo] [java11]
Java test code method collection
[Java Silver] About equals method
[Java] Timer processing implementation method
[Java] Random number generation method (Random)
Java methods and method overloads
Benefits of Java static method
[Java Silver] Array generation method
[Java] New Thread generation method (1)
Java learning (0)
Studying Java ―― 3
Java protected
[Java] Annotation
[Java] Module
Java array
Studying Java ―― 9
Java scratch scratch
Java tips, tips
Java methods
java (constructor)
to_i method
Java array
[Java] ArrayDeque
java (override)
[Java] Object-oriented syntax --class method / argument
Java Day 2018
Java string
java (array)
Java static
Java serialization
java beginner 4
JAVA paid
Automatic photo resizing method in Java
getRequestDispatcher () method
Studying Java ―― 4
Java (set)