Test.java Source code

Java tutorial

Introduction

Here is the source code for Test.java

Source

import java.io.FileOutputStream;
import java.util.Random;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Test {

    public static void main(String[] args) throws Exception {
        Lock myLock = new ReentrantLock();
        Random random = new Random();

        myLock.lock();
        int number = random.nextInt(5);
        int result = 100 / number;
        System.out.println("A result is " + result);
        FileOutputStream file = new FileOutputStream("file.out");
        file.write(result);
        file.close();
    }
}