Are you saying that some other initialization class will call your setter to initialize it? And you only want that class to be able to call it? If so, there's no standard way to do it, but... you could pass in an instance of Class to the setter, and check that it's only your initializer class. So nothing else would be able to call that method.
However, as another poster said, why not just set the value in a static initializer block, and only expose a getter? You can't change the value later on while the app is running, but it didn't sound like that was needed anyway. I think this is probably the best answer, but the other possibility I mentioned is interesting if this one won't work for some reason. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Wed, January 26, 2005 2:15 pm, Ashish Kulkarni said: > 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]