Create a java method [Memo] [java11]

class and main methods

class How to write a class.

setumeiclass.java


public class setumeiclass/*⇐ File name*/{
//Write the main method in this.
}

main method

It won't start without this. Write the code in this. (Basically.)

Test.java



public class Test{
  public static void main(String args[]){
	/*Write the code here!!*/
  }
}

Example

rei.java



public class rei{
  public static void main(String args[]){
    System.out.println("Hello,World!!");
  }
}

Execution result:

Hello,World!!

Self-made method

zisaku


public class zisaku{
public static typename method(argument){
Code executed by this method
	}
	public static void main(String args[]){
Use your own method here
	}
 
}

myclass.java


public class myclass{
	public static void main(String args[]){
		myclass(1,2); 
	}


	public static void myclass(int a,int b){
		System.out.println(a+b);
	}
}


Execution result:

3

Since the values of the arguments ʻa and bofmyclass are 1 and 2, ʻa + b (1 + 2) is 3.

Recommended Posts

Create a java method [Memo] [java11]
Java learning memo (method)
[Java ~ Method ~] Study memo (5)
Java Silver Study Method Memo
[Java] Create a temporary file
How to create a method
java (method)
Java memo
Java method
[Java] method
[Java] method
Create a Java project using Eclipse
[Java] How to create a folder
[Java] Processing time measurement method memo
Create a method to return the tax rate in Java
[Java] Create and apply a slide master
java anything memo
Java Silver memo
java, maven memo
Java8 method reference
Let's create a Java development environment (updating)
Java SE 7 memo
[Java] forEach method
Create a TODO app in Java 7 Create Header
java anything memo 2
Directory change monitoring method memo (Java, Kotlin)
java8 method reference
[Java] Random method
[Java] split method
Java specification memo
Java pattern memo
Create a CSR with extended information in Java
Create a simple bulletin board with Java + MySQL
[Windows] [IntelliJ] [Java] [Tomcat] Create a Tomcat9 environment with IntelliJ
Let's create a timed process with Java Timer! !!
Create a Lambda Container Image based on Java 15
[Java] Create something like a product search API
Try to create a bulletin board in Java
I tried hitting a Java method from ABCL
[Java] Create a collection with only one element
Let's create a super-simple web framework in Java
[Java] Let's create a mod for Minecraft 1.14.4 [Introduction]
Create Scala Seq from Java, make Scala Seq a Java List
[Java] Let's create a mod for Minecraft 1.16.1 [Introduction]
[Java] Let's create a mod for Minecraft 1.14.4 [99. Mod output]
JAVA DB connection method
Java development environment memo
Java learning 2 (learning calculation method)
java basic knowledge memo
Java Kuche Day memo
About Java method binding
java se 8 programmer Ⅰ memo
Java paid private memo
Studying Java 8 (see method)
java build a triangle
Java programming (class method)
[Java ~ Array ~] Study memo 4
Java learning memo (basic)
java lambda expression memo
(Memo) Java for statement
Java lambda expression [memo]