Tuesday, 15 March 2011

java - Modify non-static variable from inside static main function -



java - Modify non-static variable from inside static main function -

i want modify non-static variable within static main function , homecoming modified value utilize elsewhere. here code:

package servletpackage; public class blah { private int count = 5; public static void main(string[] args) { blah blah = new blah(); blah.count = 10; } // homecoming count public int getcount() { homecoming count; } }

however, when access count different file, 5 when want 10. count remain 10 within main, changes 5. how alter can homecoming 10 instead? tried rid of static in main wouldn't run. help appreciated. give thanks you!

edit: here javascript code receives returned count value of 5 instead of 10

function update3() { blah.getcount(function(data) { dwr.util.setvalue("demoreply2", data); });

java static scope non-static

No comments:

Post a Comment