Reads a double from console - Java Language Basics

Java examples for Language Basics:Console

Description

Reads a double from console

Demo Code


//package com.java2s;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    private static BufferedReader buffer = new BufferedReader(
            new InputStreamReader(System.in));

    /**/* w  ww.  j  av a2  s.  c  o  m*/
     * Reads a double from console
     * 
     * @return the read double
     * @throws IOException
     *             If an IO error occurs
     */
    public static double readDouble() throws IOException {
        return Double.parseDouble(buffer.readLine());
    }
}

Related Tutorials