Session類的構(gòu)造器是私有的。您可以獲得一個(gè)可被getDefaultInstance()方法共享的單一的默認(rèn)會(huì)話: Properties props = new Properties(); // fill props with any information Session session = Session.getDefaultInstance(props, null); 或者,您可以用getInstance()方法創(chuàng)建一個(gè)獨(dú)特的會(huì)話: Properties props = new Properties(); // fill props with any information Session session = Session.getInstance(props, null); 這兩種情形下的null參數(shù)都是一種Authenticator對(duì)象,它不是在此時(shí)使用的。具體信息請(qǐng)參閱其后的“Autherticator”一節(jié)。