evert123 Posted October 2, 2017 Share Posted October 2, 2017 Hello people of OSBot, I have a short question, if I set a variable in the private final part of the script like this: private final Position sellPoint = new Position (3209, 3216, 2); And later change this, in this case, change it to position (2222, 2222, 2) for example, in a private boolean statement or private void. 1. Will this be possible because of the private part? 2. Will it be changed back to the original (3209, 3216, 2) at any point? Hope to hear from you, and if you feel like it please leave a explanation so I can learn more from it. Quote Link to comment Share on other sites More sharing options...
HunterRS Posted October 2, 2017 Share Posted October 2, 2017 (edited) Ok, I suggest you learn some basic java before you start scripting, shouldn't take you long and it will save you a lot of time. As for your question: private means that specific var or func is only accessible from the class where you declared it. For example: If you use: private int year = 2017; in your main class, you will NOT be able to access the var year from an other class. As for the final keyword Final is a keyword that is used to declare a var as a final var, which means you can't change it. (It is constant) In order to change the sellPoint you will need to not declare it as a final. For example: this is OK private Position sellPoint = new Position (3209, 3216, 2); sellPoint = new Position (0, 0, 0); But this is NOT private final Position sellPoint = new Position (3209, 3216, 2); sellPoint = new Position (0, 0, 0); 27 minutes ago, evert123 said: Hello people of OSBot, I have a short question, if I set a variable in the private final part of the script like this: private final Position sellPoint = new Position (3209, 3216, 2); And later change this, in this case, change it to position (2222, 2222, 2) for example, in a private boolean statement or private void. 1. Will this be possible because of the private part? 2. Will it be changed back to the original (3209, 3216, 2) at any point? Hope to hear from you, and if you feel like it please leave a explanation so I can learn more from it. EDIT: A good place to start learning Java if you need: (not sure if i can post links, google "The new boston java") Edited October 2, 2017 by HunterRS 1 Quote Link to comment Share on other sites More sharing options...
d0zza Posted October 2, 2017 Share Posted October 2, 2017 the keyword final means exactly what it sounds like, whatever value you declare that variable to is FINAL, it can not be changed later on in your code. Most IDEs give an error when you try to redefine a final variable anyway. 1 Quote Link to comment Share on other sites More sharing options...
evert123 Posted October 3, 2017 Author Share Posted October 3, 2017 11 hours ago, HunterRS said: Ok, I suggest you learn some basic java before you start scripting, shouldn't take you long and it will save you a lot of time. As for your question: private means that specific var or func is only accessible from the class where you declared it. For example: If you use: private int year = 2017; in your main class, you will NOT be able to access the var year from an other class. As for the final keyword Final is a keyword that is used to declare a var as a final var, which means you can't change it. (It is constant) In order to change the sellPoint you will need to not declare it as a final. For example: this is OK private Position sellPoint = new Position (3209, 3216, 2); sellPoint = new Position (0, 0, 0); But this is NOT private final Position sellPoint = new Position (3209, 3216, 2); sellPoint = new Position (0, 0, 0); EDIT: A good place to start learning Java if you need: (not sure if i can post links, google "The new boston java") Thank you very much for the detailed explanation. I will definitely start learning more about the basics of Java, but for now I don't have much time and I use this script as a puzzle that I'm aloud to play with whenever I made some real progress with my thesis. I know this is not really efficient on my side and even less efficient on the communities side, but ill try to make up for it in the future. Quote Link to comment Share on other sites More sharing options...