Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static int[] getLine(int width, int height) { int[] lineCoordinate = new int[4]; for (int i = 0; i < 4; i += 2) { lineCoordinate[i] = (int) (Math.random() * width); lineCoordinate[i + 1] = (int) (Math.random() * height); } return lineCoordinate; } }