原文鏈接:https://blog.csdn.net/llkoio/article/details/78939148
帶資源的try語句(try-with-resource)的最簡形式為:
try(Resource res = xxx)//可指定多個資源
{
work with res
}
try塊退出時,會自動調用res.close()方法,關閉資源。
PS:在coreJava第9版的第一卷的486頁有解釋。
原文鏈接:https://blog.csdn.net/llkoio/article/details/78939148
帶資源的try語句(try-with-resource)的最簡形式為:
try(Resource res = xxx)//可指定多個資源
{
work with res
}
try塊退出時,會自動調用res.close()方法,關閉資源。
PS:在coreJava第9版的第一卷的486頁有解釋。
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。