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

2016/6/19

Problem with declaring a string variable

bernhard bernhard

2016/6/19

#
Hello, for my new scenario I want to create an actor "TextBox" that is basically just good for displaying strings. However I want it to be able to display different strings at different times. So I thought about declaring a string variable "text" and having a string passed with the constructor. Something like that:
string text;

public TextBox (string x)
{
      text = x;
}
The problem is when declaring the string it gives me the error "cannot find a Symbol - class string". Do I have to import strings? How can I solve this?
Super_Hippo Super_Hippo

2016/6/19

#
It is a class, so it has to be 'String' instead of 'string'.
bernhard bernhard

2016/6/19

#
oh thanks
You need to login to post a reply.