catch的用法

catch的用法,第1张

catch [kætʃ]
vt, vi caught, catching
1 捕捉;捉住
The cat catches mice
猫捉老鼠。
The police caught the released prisoner stealing a bicycle
释放犯偷自行车时被警察当场抓住。
She threw the ball and I caught it
她扔出了球,我接住了它。
2 捕获;猎获;诱入陷阱
A rabbit was caught in a snare
用陷阱猎获兔子。
3 无意中发现
Mother caught me stealing
母亲发现我偷东西。
4 及时赶上
The police had to drive very quickly in order to catch the train
警察只好把车开得很快,以便赶上那趟火车。
'Do you always catch such an early train' asked the inspector
`你总是赶这样的早班车吗'检查官问道。
to catch the train
赶上火车
5 受感染;染患
If you go out without a mouth mask, you'll probably catch your death of cold
如果你外出不带口罩,很可能就要患重感冒。
to catch a cold
患感冒
I'm afraid I've caught a chill
我怕我是着凉了。
You'll catch (a) cold if you don't put a sweater on
你不穿上运动衫会感冒的。
6 绊住;钩住;缠住
A nail caught her skirts
钉子钩住了她的裙子。
7 打(中);打倒
The ball caught him on the head
球打在了他的头上。
8 吸引;迷住
to catch a person's eye
引起某人的注意
I'd like another drink, try to catch the waiter's eye
我想再来一杯,看着服务员,想引起他的注意。
9 偶然碰见;发觉
I caught him doing it
他做这事时被我撞见了。
I caught a glimpse of the Town Hall clock as we drove quickly past
就在我们快速驶过市政厅时,我瞥见了那里的大钟。
I only caught a glimpse of the thief, so I can't really describe him
那个小偷我仅仅看到了一眼,所以我实在无法描绘他的模样。
10 着火;发动(车子);生效
The fire caught quickly
火燃烧得很快。
11 听到;领会
I don't quite catch on
我不很理解。
Sorry, I didn't catch what you said Could you please say it again
对不起,我没听清楚你说的话,请你再讲一遍好吗
Did you catch my idea
你懂得我的意思吗?
Jack's always the last to catch on my joke
杰克总是最后一个弄明白我的笑话。
The catch on this door seems to be broken It won't open
这扇门的门扣好象断了,门打不开了。
I'm sorry, I can't quite catch the drift of what you're saying
很抱歉,我没能弄清你说话的意思。
I didn't catch the last two words
最后两字我没听清楚。
Did you catch my idea
你懂得我的意见吗
12 当棒球接手
习惯用语:
catch one's breath
喘气;吓一跳;(由惊吓)暂时停止呼吸
n
1 抓住;稳稳地接住;接球
2 捕获物(量);(值得)获得的物(人); 很好的结婚对象
Her husband was a good catch They say he's very rich
她丈夫是个好对象,人们说他很富有。
3 挂钩;锁环
The catch on that door is broken
那门上的挂钩断了。
4 诡计;难人的问题; 蹊跷
That new car is very cheap; there must be a catch in it somewhere!
那辆新车这么便宜,里面一定有蹊跷!
That question looks easy, but there's a catch in it
那个问题看起来容易,但这里面有蹊跷。
common
catch on
流行(地);变得风行(地)
The new folk song caught on really quickly
这首新民歌流行得真快。
catch out
发觉某人的过失;发觉某人的错误;找破绽
He was caught out
他的错误被发觉了。
catch up
1 (常与with连用)赶上
You'll have to work harder to catch up with the top students in your class
要赶上班上最优秀的同学你得更加用功才行。
When she caught up with them, she saw that they had sat down and were going through the contents of the bag
当她赶上时,看到他们已坐下正在仔细查看包里的东西。
You start first, walk on and I'll catch up with you later
你们先动身,往前走,我等一会儿会赶上你们的。
2 加紧弥补
I have to catch up on my work so I can't come out
我要把工作补上,不能出去了。

相信这个搭配应该为:
try
{
//此处是要尝试运行的代码。如:打开数据库连接代码SqlConnectionOpen()
}
catch(Exception e)
{
//此处是如果try部分的任何一句代码尝试失败后,则跳转到此模块执行代码。可以获取系统错误,系统错误信息就在emessage中,也可以自己写错误信息,或者其他代码块
}
finally
{
//无论尝试是否成功都会运行此部分代码,比如连接打开了,但没有被关闭,可以在此处写上关闭此连接的代码SqlConnectionClose()
}
你现在应该明白了catch块中的含义了吧!

try/catch的功能是捕捉异常
所以在需要这个功能的时候就需要try/catch
1)java中即使不会发生异常的代码也是可以用try/catch,catch句不会被认为不可达代码
2)常见需要捕捉的异常
aIO异常:使用输入输出流读写文件的时候,
b类型转换异常:不确定被转换变量是否满足条件的时候,如下
String str = \"a\";
IntegerparseInt(str);
cDB异常:数据库 *** 作时常伴随有异常的发生


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

原文地址:https://54852.com/yw/10389209.html

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

发表评论

登录后才能评论

评论列表(0条)

    保存