Java basics: a static function without a name, or return type -
public class main { public static final logger logger = logger.getlogger(main.class.getname()); static { try { logger.addhandler(new filehandler("errors.log",true)); } catch(ioexception ex) { logger.log(level.warning,ex.tostring(),ex); } } ... i'm wondering nameless static function about.
i never saw in java (which i'm learning).
what ?
when typically used ?
when gonna executed in program ?
that called static block , executed once during initialization. also, if there more 1 static initialization blocks, run time guarantees called in order appear in source code.
here pretty explanation example code @ bottom of page. http://isagoksu.com/2009/development/java/understanding-static-blocks/
Comments
Post a Comment