Skip to content

Instantly share code, notes, and snippets.

@cxubrix
Created August 29, 2019 18:29
Show Gist options
  • Save cxubrix/ee11b383282748f793f0f55507c02288 to your computer and use it in GitHub Desktop.
Save cxubrix/ee11b383282748f793f0f55507c02288 to your computer and use it in GitHub Desktop.
import java.util.Random;
public class MethodsExamples {
public static void main(String[] args) {
int x = getRandomNumber();
helloKitty();
hello("Kitty");
hello("Student");
hello("Teacher");
int y = getRandomNumber();
System.out.println("x: " + x);
System.out.println("y: " + y);
int avg = avg3(4, 39, 53);
System.out.println("avg: " + avg);
}
public static void helloKitty() {
hello("Kitty");
}
public static void hello(String name) {
System.out.println("Hello " + name + "!!");
}
public static int getRandomNumber() {
return new Random().nextInt(99);
}
public static int avg3(int a, int b, int c){
int result = ((a + b + c) / 3)
return result ;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment