This site requires JavaScript, please enable it in your browser!
Greenfoot back
bernhard
bernhard wrote ...

2014/1/4

Read a String

bernhard bernhard

2014/1/4

#
I want to display a word that was typed by the keyboard before. Therefore I declared a String:
private String newPlayer;
I worked with Eclipse before and tried to give the String a value just like I used to do in Eclipse:
newPlayer = in.readString();
It didn't work out, it said "cannot find variable in". I remeber that I used a class called "in" to do this in Eclipse. Is there also such a class for Greenfoot? If not, how can I get this to work?
danpost danpost

2014/1/4

#
The standard input stream is referred to by 'System.in' and it is an InputStream object. However, there is no 'readString' method of that class. Please see the documentation for the InputStream class. BTW, there were only two 'readString' methods listed in the java index and both were SQL related.
bernhard bernhard

2014/1/4

#
Okay that's a pitty. I guess I'll just leave that out. Thank you anyway
You need to login to post a reply.