Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm using a library it has a public static float variable I want to know how to override it I guess that's not going to happen?

//Settings.java
package org.jbox2d.common;

public class Settings {
    public static float velocityThreashold = 1.0f;
}

//MyClass.class
package org.jbox2d.common;

import com.otherlibrary
public class MyClass {

}

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
728 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can not override member variables in Java. You can use something called field hiding instead. Have a look at this.

However in your example velocityThreashold isn't final so you can change it's value.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...