public class MyClass {
void myMethod() {
System.out.println("You have called me! My name is: myMethod!");
}
public static void main(String[] args) {
new MyClass().myMethod();
}
}
public class Y{
public static void main(String args[]){
X foo = new X();
foo.setSubtotal();
}
}
public class X{
public void setSubtotal ()
{
subtotal = Validator.getDouble(sc,"Enter subtotal:", 0, 10000);
}
}
int a = 20;
int b = 20;
public static void sum(){ // Void Method
System.out.println(a + b);
}
public static int sum(){ // Return Function
return a + b;
}
public class methods{
public static void main(String[] args){
printSum(5, 15); // Print 20
}
public static void printSum(int a, int b){
System.out.println(a + b);
}
// Our method should be outside the main methods bounds
// Call your function inside the main method.
}
// calls the method
addNumbers();