Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 184719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:20:31+00:00 2026-05-11T15:20:31+00:00

I’m working on a Bruce Eckel exercise on how to take a keyboard command

  • 0

I’m working on a Bruce Eckel exercise on how to take a keyboard command line input and put it into an array. It’s supposed to take 3 separate inputs and place them into an array and print them back out.

Here is the code I have so far:

//: object/PushtoArray import java.io.*; import java.util.*;  class PushtoArray {      public static void main(String[] args) {      String[] s = new String[3];      int i = 0;       //initialize console      Console c = System.console();         while ( i <= 2 ) {         //prompt entry:         //System.out.println('Enter entry #' + i + ': ');           //readin              s[i] = c.readLine('enter entry #' + i + ': ');           //increment counter          i++;                      } //end while       //reset counter      i = 0;       //print out array     while ( i <= 2 ) {          System.out.println(s[i]);             i++;     } //end while      }//end main  } //end class 

UPDATE: Now I get a different error:

PushtoArray.java:15: readline(boolean) in java.io.Console cannot be applied to (java.lang.string)        s[i]= c.readline('Enter entry #' + i + ': '); 

I’m trying to read in from the command prompt but it isn’t prompting at all. It compiles correctly when I javac the java file.

Am I using the wrong function? Should I be using a push method instead of an assignment?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:20:32+00:00Added an answer on May 11, 2026 at 3:20 pm

    Are you sure you’re running javac on the right file? There is no way that file could compile.

    1. You need a semicolon on the import statement:

      import java.io.*; 
    2. You forgot an end brace:

      } // end main() 
    3. There is no such method as readline(). You need to read from System.in. The easiest way is to make a Scanner before the loop, then read from it in the loop. See the Javadocs for Scanner for an example.

    Edit: See the Java Tutorials for more on reading from the command line. The Console class (introduced in Java 6) looks like it has the readLine() method that you wanted.

    Edit 2: You need to capitalize Line. You wrote ‘readline‘, but it should be ‘readLine‘.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 184k
  • Answers 184k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Did you put a trace in the setter to make… May 12, 2026 at 4:45 pm
  • Editorial Team
    Editorial Team added an answer The reason you are getting the spark code instead of… May 12, 2026 at 4:45 pm
  • Editorial Team
    Editorial Team added an answer Apache Commons has a Net component that does FTP uploads… May 12, 2026 at 4:45 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.