Results are out! Find what you need...fast. Get quick advice or join the chat
Hey there! Sign in to join this conversationNew here? Join for free

How do I rename a variable (NetBeans)

Announcements Posted on
Applying to Uni? Let Universities come to you. Click here to get your perfect place 20-10-2014
    • Thread Starter
    • 3 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
    • 3 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
    • 3 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
    • 3 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?
  2. this can't be left blank
    this email is already registered. Forgotten your password?
  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 joining you agree to our Ts and Cs, privacy policy and site rules

  2. Slide to join now Processing…

Updated: July 15, 2012
New on TSR

Personal statement help

Use our clever tool to create a PS you're proud of.

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.