java中,有try没catch有finally怎么用?

java中,有try没catch有finally怎么用?,第1张

有try 和finally没catch,有异常将抛出,但不会提示你,finally里的东西都会执行,finnally主要是关闭数据库用的,你以后就会明白try{}catch+finally的用法

Finally英文意思是最后、最终的意思。但是它也是一首歌的名字
Finally
歌手:王力宏
专辑:盖世英雄(抢听版)
明知留不住
更不想
努力记住你此刻的眉目
记住这拥抱的温度
对抗快来临的孤独
为什么幸福它总促
不在乎付出
因为我在乎
但让你哭我就无可宽恕
年轻的太低估
世界该有的冷酷
太多的爱
也没帮助
My
Finally
一个也吻
Finally
我最终的恋人别哭泣
用力用力忘你在哪里
我的心中不曾离开你
永远的
当我想起你
会得到
爱的离奇
我要退出
也为你祝福
别为我哭
我会嫁给无助
年轻的太低估
世界该有的冷酷
太多的爱
也没帮助
My
Finally
一个也吻
Finally
我最终的恋人别哭泣
用力用力忘你在哪里
我的心中不曾离开你
永远的
当我想起你
会得到
爱的离奇
忘记一步一切就荒芜
希望爱复燃吧!
My
Finall
一个也吻
Finally
我最终的恋人别哭泣
用力用力忘你在哪里
我的心中不曾离开你
永远的
当我想起你
会得到
爱的离奇!

最后的最后用英文表示为:Last end,其中Last的英式发音为[lɑ:st],美式发音为[læst]  ,意思有:最后,末尾,上个,鞋楦(做鞋的模型),最后的,最近的,最不可能的,惟一剩下的。

Last end的用法

1、最后一排的最后一个人是谁?

Who is the last person in the last row

2、几个月前,在芳汀刚刚失去她最后的贞 *** 、最后的羞耻、最后的欢乐时,她还算得上是自己的影子,现在她只是自己的幽灵了。

Some months before this, at the moment when Fantine had just lost her last modesty, her last shame, and her last joy, she was the shadow of herself; now she was the spectre of herself

3、只要她还走在面包师巷和礼拜堂左近一带地方,总还有店铺里的烛光替她照路,可是最后一个摊子的最后一点微光也终于消逝了。

So long as she was in Boulanger Lane and in the neighborhood of the church, the lighted stalls illuminated the road; but soon the last light from the last stall vanished

4、9月的最后一个星期六,我收到了克莱夫的最后一封信。

On the last Saturday in September, I received a final letter from Clive

5、the last hurrah(最后的欢呼)也意味着一个政治家任期结束前最后的行动。

The last hurrah also can mean the last acts of a politician, before his term in office ends

6、它从前的几位头号敌人,包括蛾形巨型生物摩斯拉也在新片《哥斯拉:最后战争》中再次现身。学者影业公司声称这是他们制作的最后一部哥斯拉&至少现在来说是这样的。

Several of his former outsized foes, including the giant moth-like creature Mothra, make comeback appearances in "Final Wars," which Toho is touting as its last Godzilla tale& at least for now

7、知更雀每晚最后一件工作就是歌唱,当它们做完了一天的工作,飞完了最后一次任务,捡起了最后一颗食粮,便停住在树枝的高处,唱出赞美的歌声。

Singing is the last thing that robins do When they have done their daily work; when they have flown their last flight, and picked up their last morsel of food, then on a topmost twig, they sing one song of praise

8、我相信人应该就象天天都是最后的日子那样生活,这可以解释为什么我没有干净衣服&因为,得了吧,谁在生命的最后几天里还想洗衣服?

I believe you should live each day as if it is your last, which is why I don't have any clean laundry because, come on, who wants to wash clothes on the last day of their life

try catch主要是处理一些不可预料的异常。比如连接数据库失败,保存文件时没权限、路径错误等问题。用try捕捉这些异常后,再在catch进行处理,可以给用户提示更友好的出错信息。而且finally里面的代码必定会执行,这样的好处就是:比如数据库连接已经打开 ,然后执行其他代码发生了异常,这样就可以在finally里面将数据库连接关闭,这样就保证了之前打开的数据库连接一定会关闭,避免暂用不必要的资源。
希望对你有用!


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/10403586.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-08
下一篇 2023-05-08

发表评论

登录后才能评论

评论列表(0条)

保存