#guys I can use a variable in another

1 messages · Page 1 of 1 (latest)

placid inlet
#

Show code

#

If you need to use from another class, declare outside of onEnable() and initialize it inside

noble geyser
#

oh ok

#

public void onEnable() {
boolean drop = true;

placid inlet
#

I mixed them up

#

So do

noble geyser
#

thats not working when i want to use it

placid inlet
#
  boolean drop;

public void onEnable() {
this.drop = true;
}
noble geyser
#

oh after i can use it in another file

#

thx

placid inlet
#

Well, depends

#

Do you pass an instance of main to the class you want to use it from?

#

new OtherClass(this)

placid inlet
#

Then yes

noble geyser
#

you just solved a lot of my problems. thanks bro

placid inlet
#

Either make boolean drop;

public boolean drop;

or

private boolean drop;

and make

return this.drop
}
#

I usually use the second one

#

make the field private then make the getter and/or setter