1

just a another noob to Java with a dumb question.
I am trying to create a function that receives a String array and fills it with text input from the user using Bufferedreader (which I currently want to use). I sort of have the idea in my head but it gives the error cannot find symbol when using the readline() property. How can I achieve this?

public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

public static void fill_array (String parray []){

        for(int i = 0; i < parray.length; i++){
            parray[i] = in.readline(); //Here it gives me the error
        }
    }

2
  • 4
    It must be readLine() and not readline() Commented Sep 16, 2019 at 4:03
  • @user7 no way! xD thanks. Commented Sep 16, 2019 at 4:04

2 Answers 2

2

readLine() and not readline how embarrasing

Sign up to request clarification or add additional context in comments.

2 Comments

@Rich umm, it answers the question exactly? Could have been worded better but put some effort into the reviews.
Though, to be fair, such a question should be closed for being caused by a typo, rather than answered
1

Hii Scanner is much more simpler than BufferedReader to read input, Let me give you an example :

import java.util.*;

public class Main
{
  public static void main(String arp[])
  {
    Scanner scanner = new Scanner(System.in);
    String address = scanner.nextLine(); // read string with spaces
    System.out.println("addres : "+ address);
    String name = scanner.next(); // read string without spaces
    System.out.println("name : "+ name);
    Integer age = scanner.nextInt();  // read Integer input
    System.out.println("age : "+ age);
  }
}

Scanner java api link : https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.