public MyClass { private boolean isInitialzed = false; private static String data; public static String getData() { return data; } public static setData(String input) { if (! isInitialzed) { data = input; isInitialzed = true; } }
} ----- Original Message ----- From: "Ashish Kulkarni" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <user@struts.apache.org> Sent: Wednesday, January 26, 2005 8:15 PM Subject: Re: [OT] a java question > so it will be some thing like this > > public MyClass > { > private static String data; > public static String getData() > { > return data; > } > public static setData(String input) > { > data = input; > } > > } > this will work, but how to make sure that setData is > called only from initalization class, and no one else > calls this method , how to protect this method from > being called by other classes > > Ashish > --- PA <[EMAIL PROTECTED]> wrote: > > > > > On Jan 26, 2005, at 20:08, Ashish Kulkarni wrote: > > > > > how do i protect it from updated > > > by any other class. > > > > Just don't. Use a static accessor method instead. > > > > Cheers > > > > -- > > PA > > http://alt.textdrive.com/ > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > > [EMAIL PROTECTED] > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > > > > > > __________________________________ > Do you Yahoo!? > Yahoo! Mail - Find what you need with new enhanced search. > http://info.mail.yahoo.com/mail_250 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]