1package com.company;
2
3public class Main {
4 static void one(){ // youCanPutWhatEverNameYouLikeInThePlaceOf"One"
5 System.out.println("HELLO");
6 }
7 public static void main(String[] args) {
8 one(); //theTerminalShouldSay"HELLO"
9 }
10}
11
1public class Main
2{
3 static void function(){
4 System.out.println("I am a function!");
5 }
6 public static void main(String[] args) {
7 function();
8 }
9}
1//declare a function like this:
2void function(int parameter1)
3{
4 //function body
5}
6//call the function like this:
7function(1);
1public class MyClass {
2 static int myMethod(int x) {
3 return 5 + x;
4 }
5
6 public static void main(String[] args) {
7 System.out.println(myMethod(3));
8 }
9}
10// Returns 8
1public class main {
2 public static void function {
3 // Write your code here
4 }
5}