Java examples for Language Basics:Console
Reads a float from console
//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)); /**/*from ww w.j a v a 2 s .c o m*/ * Reads a float from console * * @return the read float * @throws IOException * If an IO error occurs */ public static float readFloat() throws IOException { return Float.parseFloat(buffer.readLine()); } }