Java examples for Object Oriented Design:Method
A program that uses a method that determines a random number between 1 and 10:
public class RandomNumber { public static void main(String[] args) { int number = getRandomNumber(); System.out.println("The number is " + number); }//w ww .j a v a2s. co m public static int getRandomNumber() { int num = (int)(Math.random() * 10) + 1; return num; } }