Monday, 26 August 2013

Accessing java member variable that has the name "type"

Accessing java member variable that has the name "type"

I am using a java library in which a class has a member named "type". If I
do something like this:
class MyClass{
public MyClass(){
type = 5;
}
public int type;
}
then the java compiler compiles it fine. But if I try to access it from
scala:
val x = new MyClass()
x.type = 10
I get this message:
identifier expected but 'type' found.
How do I work around this issue?
I am guessing this has come up before but I could not find a related
question.

No comments:

Post a Comment