freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

產(chǎn)品庫存管理系統(tǒng)面向?qū)ο笤O(shè)計(參考版)

2025-02-20 06:21本頁面
  

【正文】 下課了!演講完畢,謝謝觀看!。課下實戰(zhàn)q用 Java語言描述 IBM公司的員工,其中員工和經(jīng)理的薪水是不同的,其工作的方式也是不同的。e){(())。}catchtry{(5)。my=newmain(Stringstaticelse(登記的人數(shù)為: +num)。newthrowsregister(intpublicTestMyException{id。int=id。message,intpublicintextends用戶自定義異常示例 33class}(“捕獲異常 ”+());catch(ExceptionArithmeticException()。throwtry{ intargs[])voidpublicclass例如: throw new ArithmeticException()。throw語句的一般形式q一般的形式是: throw new 異常類 ()。1語句 3throw任務(wù)十q編程判斷一個數(shù)能否被 3整除,如果不能整除就讓它拋出一個異常。 (result)。(9,resultExceptionRaised()。={ExceptionRaisedthrowsmain(String[]staticArithmeticExceptionresult。/=result=0。throwsintintint{ExceptionRaisedqtrycacthfinally語句中間不能插入其他語句聲明拋出異常處理異常 處理異??赡軙?dǎo)致異常 防止被調(diào)用的方法出現(xiàn) 異常并處理異常type calledmethodname(parameterlist) throws exceptionlist{ // body of method}type callingmethodname {try { // statements calledmethodname()。}}思考:如果沒有finally語句,程序運行的結(jié)果有何不同?trycatchfinally應(yīng)注意的問題q每個 try語句至少有一個 catch語句對應(yīng),catch語句的排列順序應(yīng)該從特殊到一般。}}{}catch(ArithmeticException0用作了除數(shù)b)。(a=int=intargs[]){voidpublicSystemException{無異常異常異常處理塊的一般形式try{ // 要監(jiān)控錯誤的代碼塊} catch (Exception e) { // Exception e 的異常處理程序} finally{ // 在 try 結(jié)束前要執(zhí)行的代碼塊}finally塊示例public塊塊catchtry }}finally 塊try、 catch 和 finally 塊的執(zhí)行流程vfinally子句可以保證,無論 try塊中是否拋出異常,finally塊中的語句都會被執(zhí)行到,這樣可以對程序的狀態(tài)作統(tǒng)一的管理。}}class UnreachableCode {public static void main(String[] args) { ExceptionCode obj = new ExceptionCode()。}類 ,且不能到達(dá) )。不能到達(dá)的代碼錯誤 {(ArithmeticException子句 )。(父類異常 e)}catch=1, 2, 3, 4=intnum。42num1=inttry{voidExceptionCode……}多重 catch 塊 22try{ …...} catch(Exception e) { ……} catch(ArrayIndexOutOfBoundsException e) { ……} q使用多重 catch 語句時,異常子類一定要位于異常父類之前。{catch(Exceptione)…….}}} 多重 catch 塊 21q一段代碼可能會生成多個異常q當(dāng)引發(fā)異常時,按順序查看每個 catch 語句,并執(zhí)行第一個類型與異常類型匹配的語句q執(zhí)行其中的一條 catch 語句之后,其他的 catch 語句將被忽略try{ex=newmain(Stringstatic}(array[+i+]=+array[i])。ij。(intexceptest(intpublicarray[]={1,2,3,4,5,6,7,8,9,0}。ExceptionDemo{publicresult。()。+(發(fā)生異常: {(Exception/=result=0。operand2)operand1,calculate(public}ExceptionRaised()public{class tryfinally catch要監(jiān)控的程序語句包含在此塊中以合理的方式捕獲和處理異常釋放資源等try 和 catch 塊執(zhí)行 catch 后程序繼續(xù)正常運行程序控制 引發(fā)代碼塊trycatch異常單 常程序突然終止并將控制交給操作系統(tǒng)? 在運行時發(fā)生的錯誤 什么是異常q在程序運行過程中發(fā)生的、會打斷程序正常執(zhí)行的事件稱為異常( Exception),也稱為例外。 (result)。 } public static void main(String[] args) { ExceptionRaised obj = new ExceptionRaised()。}}顯示所有命令行參數(shù)Java異常處理任務(wù)九public class ExceptionRaised { public ExceptionRaised() { } public int calculate( int operand1, int operand2) { int result = operand1 / operand2。args[i])。+]:i(args[for(intargs[])voidpublicCommandLineyou?HowHelloEcho123q若要將包含多個空格的單詞作為一個字符串,可用引號括起來。areHelloEcho}}main方法的參數(shù)qmain方法的形參為 String類的數(shù)組參數(shù)args, args可以用來接收 Java命令行傳送給 Java應(yīng)用程序的數(shù)據(jù)。i){((i))。i=len1。StringBuffer(len)。StringBufferintas=Imain(String[]staticclass (s)。//轉(zhuǎn)換為字符串()。s4)。 (start,= int= int)。39。23。 index)。 (index,5。index (3)。Ver1/”)。 (“newbuf[]args)void{publicclassendstarts)使用一 組 字符替 換 另一 組 字符。end,start,指定的索引 處 的字符StringBufferpos)刪 除 位置的字符序列StringBuffer– end start int delete(int) 轉(zhuǎn)換為 字符串形式StringBuffer指定的位置上的字符String指定的新 值設(shè) 置 ch) 使用 pos,voidcapacity()StringBufferlength(insert(String16(int個字符的空 間publicStringBuffer() 保留 }}任務(wù)八 判斷一個字符串是否為回文,即將一個字符串進(jìn)行反轉(zhuǎn),得到的字符串與源串相同:例如原始字符串為 “aba”, 逆轉(zhuǎn)后的字符串也為 “aba” 。()。nameUppercase)。個字符 )。++ (“姓名的長度為 = int+String(Gee)。= String{[]void{publicclasstoLowerCase()。語法PublicString)方法 HELLOHELLO使用 toUpperCase((())。GetFilename(F:\\ava\\myexample\\)。args){GetFilenamevoid}}public}else{returnif(pos==1){returngetPath(){int}}publicfullPath。pos=(pathSepatator)。Stringfname){ fullPath=fname。\\39。charprivateStringclassw39。, ((39。 ((World))。 ((3,+(39。=of(t,))。+(39。=of (lastt39。+=of (s)。= Stringworld= Stringindependent+aJavasargs)main(StringstaticStringMethodspublicch = orange.charAt(3)。public String trim() 此方法用于返回一個前后不含任何空格的調(diào)用字符串的副本。public String concat(String str) 此方法用于連接兩個字符串,并新建一個包含調(diào)用字符串的 String 對象。public String substring(int index) 此方法用于提取從位置索引開始的字符串部分。 (“該電子郵件地址無效 )。else (“該電子郵件地址有效 )。))(39。)((39。 ))。(39。的索引是 :))。(39。的索引是 :name)。ID= String{main(String[]staticSearchString2: 如果沒有找到匹配,則返回 1返回找到的第一個匹配的位置索引搜索字符串舉例public1:indexOf(character)搜索字符串字符串 endsWith(Stringvalue) 檢查 一個字符串是否以另一個字符串開始。如果兩個字符串相等, 則 返回 0;如果字符串在 該值 之前, 則 返回 值 小于 0;如果字符串在 該值 之后, 則 返回 值 大于 0booleanpareTo(String(String}}字符串比較舉例程序運行結(jié)果如下:truetruefalsetrue思考:為什么?Java在編譯時對字符串常量的存儲有一個優(yōu)化處理策略 ,相同字符串常量只存儲一份 字符串比較方法方法
點擊復(fù)制文檔內(nèi)容
畢業(yè)設(shè)計相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1