try的意思 在什么時(shí)候需要用try?
在什么時(shí)候需要用try?需要捕獲程序未處理的異常情況時(shí)使用,提供程序穩(wěn)定性,不用則可能導(dǎo)致程序崩潰,停止運(yùn)行.一般采用這種形式try{ int res=1/0這里就會(huì)出現(xiàn)除數(shù)不能為0的異常}ca
在什么時(shí)候需要用try?
需要捕獲程序未處理的異常情況時(shí)使用,提供程序穩(wěn)定性,不用則可能導(dǎo)致程序崩潰,停止運(yùn)行.一般采用這種形式try{ int res=1/0這里就會(huì)出現(xiàn)除數(shù)不能為0的異常}catch(Exception){ //處理未捕獲的異常.}finnaly{}
try to do和try doing有什么區(qū)別?分別用在什么時(shí)候?
try to do 表示“努力做...事”Try doing表示“嘗試做...事”。例如: He didn”t try to do it. 他不肯努力去干 She tried washing her hair with a new shampoo. 她試著用一種新的香波洗頭發(fā)?! lease try to finish this work in thirty miniutes. 請盡量在30分鐘完成這項(xiàng)工作?! hy didn"t you try riding a bike to go to school? 為什么不試著騎車去學(xué)校呢?注:try to do sth.表示"試圖干……",強(qiáng)調(diào)付出努力,但不一定成功 try doing表示"嘗試干、干……試試",含有"看結(jié)果如何"之意。
什么時(shí)候用try not to do什么時(shí)候用not try to do?
trytodo的意思是盡力去做某事。如果是trynottodo,就翻譯為:盡量別去做某事,這里否定的是動(dòng)詞do如:Pleasetrynottomessthesethingsup:盡量別把事情搞砸了,重點(diǎn)在于別把事情搞砸了。如果是nottrytodo,就翻譯為:不要試圖做某事(想都別想)。這里否定的是動(dòng)詞try。如:Donottrytotrickintheexam.考試過程中別試圖作弊。(不要有作弊的想法,念頭),重點(diǎn)在于不要有這種念頭和想法。祝進(jìn)步。