Jump to content

Private final


evert123

Recommended Posts

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.

 

 

Link to comment
Share on other sites

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 by HunterRS
  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...