java - deactivate a variable after use -



java - deactivate a variable after use -

is there annotation can allow me tell java compiler variable not supposed used after annotation? autofill , re-create paste features of modern ides, easy introduce bugs mistyping variable names. such annotations help observe of bugs @ compile time (or @ typing time if 1 using smart ides netbeans/eclipse). example, have next string processing pipeline:

string input = .... string pass1 = op1 (input); ... string pass2 = op2 (pass1); ... string pass3 = op3 (pass1); // typo: pass1 should pass2 ... homecoming pass3;

if disable pass1 after line op2 called, typo in line op3 called detected pass1 out of scope result of hypothetical disable annotation.

no, cannot deactivate variables in java. alternative, reuse variables, instead of creating new ones:

string input = .... string currentpass = op1 (input); ... currentpass = op2 (currentpass); ... currentpass = op3 (currentpass); ... homecoming currentpass;

in theory, sufficiently smart ide utilize java annotations throw warning. however, bad idea. syntax ugly, , tie particular ide. additionally, there no java ides implement 'feature'.

java encapsulation

Comments

Popular posts from this blog

c# - ASP.NET MVC Sequence contains no matching element -

java - Parsing XML, skip certain tags -

rest - How to invalidate user session on inactivity in a stateless server? -