function in java
public class Main
{
static void function(){
System.out.println("I am a function!");
}
public static void main(String[] args) {
function();
}
}//declare a function like this:
void function(int parameter1)
{
//function body
}
//call the function like this:
function(1);public int addNum(int num1, int num2) {
total = num1 + num2;
System.out.println("Total: " + total);
}public static void main(String[] args)
{
int length=getLength();
System.out.println("Your length is: "+length);
}
//methods are outside of main method
public static int getLength()
{
int length=5;
return length;
}
Also in Java:
- java integer compareto
- java how to print a newline
- java hashmap size
- working with buttons in applet java
- binary search java
- how do you make a method that returns an array java
- string array in java methods
- java character for end of file
- java if a or b
- biginteger in java
- best companies to workk in
- java remove non numbers from string
- split method in java
- java file download
- how to make a button disapear on click in javafx
- write an object java in a file
- android java retrofit offline cache
- connect 2 package in android
- java type casting
- how to detect if someone clicks on a jpanel in java
- how to add element to arraylist
- how to use for loop for array in java
- int to binary java
- kotlin jsonobject get nested