Hey there Sign in to join this conversationNew here? Join for free

How do I rename a variable (NetBeans)

Announcements Posted on
We're up for a Webby! Vote TSR to help us win. 10-04-2014
    • Thread Starter
    • 4 followers
    Offline

    ReputationRep:
    Hi,

    I want to rename a variable (correct typo) in my project which I'm doing using NetBeans. The thing is I've already used the variable (with the typo) in other classes so changing it would make a big mess.

    Help please
    • 8 followers
    Offline

    ReputationRep:
    Select the variable, right click then go to Refactor>rename, should work fine...
    • Thread Starter
    • 4 followers
    Offline

    ReputationRep:
    (Original post by iCiaran)
    Select the variable, right click then go to Refactor>rename, should work fine...
    I know that but will it change every appearance of the variable name to the new name even in other classes?
    • 8 followers
    Offline

    ReputationRep:
    (Original post by Prokaryotic_crap)
    I know that but will it change every appearance of the variable name to the new name even in other classes?
    It should, I haven't used NetBeans before so I can't say for certain, it should definitely do it in the class you select it in, you may have do it in each class though...

    On a side note, are you really using the exact same variable in multiple classes? Or just variables called the same thing?
    • Thread Starter
    • 4 followers
    Offline

    ReputationRep:
    (Original post by iCiaran)
    It should, I haven't used NetBeans before so I can't say for certain, it should definitely do it in the class you select it in, you may have do it in each class though...
    I know it works when you do it on the class you select it from, I've done it before, but I don't know if it works on all classes that use the variable and I don't want to do it on every single class that uses it because my project is quite bug and complex with many classes.

    (Original post by iCiaran)
    On a side note, are you really using the exact same variable in multiple classes?
    yes, I'm using the exact variable in multiple classes.
    • 1 follower
    Offline

    ReputationRep:
    Why do you need to store the same information twice?
    • Thread Starter
    • 4 followers
    Offline

    ReputationRep:
    (Original post by Planto)
    Why do you need to store the same information twice?
    I'm not?

    e.g. I have a variable x and getter and setter methods for it and I want to change x but other classes are using its setter and getter methods.
    • 8 followers
    Offline

    ReputationRep:
    Honestly, just go and refactor it in every class, there can't be that many and it would have been done hours ago if you did...

Reply

Submit reply

Register

Thanks for posting! You just need to create an account in order to submit the post
  1. this can't be left blank
    that username has been taken, please choose another Forgotten your password?

    this is what you'll be called on TSR

  2. this can't be left blank
    this email is already registered. Forgotten your password?

    never shared and never spammed

  3. this can't be left blank

    6 characters or longer with both numbers and letters is safer

  4. this can't be left empty
    your full birthday is required
  1. By completing the slider below you agree to The Student Room's terms & conditions and site rules

  2. Slide the button to the right to create your account

    Slide to join now Processing…

    You don't slide that way? No problem.

Updated: July 15, 2012
Article updates
Useful resources
Reputation gems:
You get these gems as you gain rep from other members for making good contributions and giving helpful advice.