Hi, I have the following code below but i need to populate a string array dynamically(size and content are defined by the user of the program) but i'm having difficulty with the assignment statement. i.e
In what way does it fail ? The code looks fine assuming that the readString method returns a String. [ May 19, 2008: Message edited by: Joanne Neal ]
Joined: Apr 16, 2008
The readString method does not really exist. for example, we have methods that read in the input of the user into number variables.. for acm we have readInt(), readDouble(), etc for java we have nextInt(), nextDouble(), etc.
but there is no provision for reading in a string value to a variable.
Those readInt() etc. methods are implemented in one of the superclasses. The class ConsoleProgram is not a class from the standard Java API, so I can't tell you how to use it.
A quick Google search for "ConsoleProgram" found the API documentation for acm.program.ConsoleProgram - that seems to be the class you're using. Note that according to that documentation there is indeed no readString() method, but there is a readLine() method. You could try using that.
Note about the following line in your program:
This is not valid Java code. There is no "using" statement in Java. You probably meant:
import acm.program.*; [ May 19, 2008: Message edited by: Jesper Young ]