-2

THIS IS MY PROGRAM:

import java.io.*;
public class Inputing
{
  public static void main(String ar[]) throws IOException
  {
   InputStreamReader isr=new InputStreamReader(System.in);
   BufferedReader br=new BufferedReader(isr);
   System.out.println("\nEnter a value: ");
   int a;
   a=br.read(ar[0]);
   System.out.print("The entered value is: "+a); 
  }
 }

THIS IS MY ERROR:

Inputing.java:10: error: no suitable method found for read(String)
a=br.read(ar[0]);
^
user207421
  • 305,947
  • 44
  • 307
  • 483
  • 1
    There isn't a method read that takes only one string type argument. Check the docs here, https://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html – doublezofficial May 20 '20 at 04:18
  • 1
    When you wrote `br.read(ar[0])`, what were you trying to do with `ar[0]`? – Ry- May 20 '20 at 04:34

1 Answers1

1

The error is self-explanatory. There is no read(String) method on the BufferedReader class. See the Java docs.

BufferedReader indeed has a read method that takes 3 parameters - a character array, an offset and a length value - as arguments. You might want to use that variant instead.

VHS
  • 9,534
  • 3
  • 19
  • 43