How do I rename a variable (NetBeans)

From C++ to PHP, debugging to webhosting; help and discussion about writing your latest program to running your website. NOT for help when your PC won't work.

Announcements Posted on
TSR launches Learn Together! - Our new subscription to help improve your learning 16-05-2013
Sign in to Reply
  1. Prokaryotic_crap's Avatar
    • TSR Demigod
    • Location: Em City, Oz
    How do I rename a variable (NetBeans)
    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
  2. iCiaran's Avatar
    • Exalted and Worshipped Member
    • Location: Wirral
    • Posts: 1,234
    Re: How do I rename a variable (NetBeans)
    Select the variable, right click then go to Refactor>rename, should work fine...
  3. Prokaryotic_crap's Avatar
    • TSR Demigod
    • Location: Em City, Oz
    Re: How do I rename a variable (NetBeans)
    (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?
  4. iCiaran's Avatar
    • Exalted and Worshipped Member
    • Location: Wirral
    • Posts: 1,234
    Re: How do I rename a variable (NetBeans)
    (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?
  5. Prokaryotic_crap's Avatar
    • TSR Demigod
    • Location: Em City, Oz
    Re: How do I rename a variable (NetBeans)
    (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.
  6. Planto's Avatar
    • TSR Idol
    • Posts: 8,690
    Re: How do I rename a variable (NetBeans)
    Why do you need to store the same information twice?
  7. Prokaryotic_crap's Avatar
    • TSR Demigod
    • Location: Em City, Oz
    Re: How do I rename a variable (NetBeans)
    (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. iCiaran's Avatar
    • Exalted and Worshipped Member
    • Location: Wirral
    • Posts: 1,234
    Re: How do I rename a variable (NetBeans)
    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...
Sign in to Reply
Share this discussion:  
Useful resources
Article updates
Moderators

We have a brilliant team of more than 60 volunteers looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

Reputation gems:
The Reputation gems seen here indicate how well reputed the user is, red gem indicate negative reputation and green indicates a good rep.
Post rating score:
These scores show if a post has been positively or negatively rated by our members.