计算机专业毕业设计外文翻译29

计算机专业毕业设计外文翻译29

ID:10920166

大小:115.50 KB

页数:22页

时间:2018-07-08

计算机专业毕业设计外文翻译29_第1页
计算机专业毕业设计外文翻译29_第2页
计算机专业毕业设计外文翻译29_第3页
计算机专业毕业设计外文翻译29_第4页
计算机专业毕业设计外文翻译29_第5页
资源描述:

《计算机专业毕业设计外文翻译29》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、来自:thinkinjava(3)外文原文ThebusyJavadeveloper'sguidetoScala:ClassactionItmakessenseforJava™developerstouseobjectsasafirstpointofreferenceforunderstandingScala.InthissecondinstallmentofThebusyJavadeveloper'sguidetoScalaseries,TedNewardfollowsabasicpremiseoflanguagemeasurement:tha

2、tthepowerofalanguagecanbemeasuredindirectrelationtoitsabilitytointegratenewfacilities--inthiscase,supportforcomplexnumbers.Alongthewayyou'llseesomeinterestingtidbitsrelatedtoclassdefinitionsandusageinScala.Inlastmonth'sarticle,yousawjustatouchofScala'ssyntax,thebareminimumne

3、cessarytorunaScalaprogramandobservesomeofitssimplerfeatures.TheHelloWorldandTimerexamplesfromthatarticleletyouseeScala'sApplicationclass,itssyntaxformethoddefinitionsandanonymousfunctions,justaglimpseofanArray[],andabitontype-inferencing.Scalahasagreatdealmoretooffer,sothisa

4、rticleinvestigatestheintricaciesofScalacoding.Scala'sfunctionalprogrammingfeaturesarecompelling,butthey'renottheonlyreasonJavadevelopersshouldbeinterestedinthelanguage.Infact,Scalablendsfunctionalconceptsandobjectorientation.InordertolettheJava-cum-Scalaprogrammerfeelmoreath

5、ome,itmakessensetolookatScala'sobjectfeaturesandseehowtheymapovertoJavalinguistically.Bearinmindthatthereisn'tadirectmappingforsomeofthesefeatures,orinsomecases,the"mapping"ismoreofananalogthanadirectparallel.Butwherethedistinctionisimportant,I'llpointitout.Scalahasclass(es)

6、,tooRatherthanembarkonalengthyandabstractdiscussionoftheclassfeaturesthatScalasupports,let'slookatadefinitionforaclassthatmightbeusedtobringrationalnumbersupporttotheScalaplatform(largelyswipedfrom"ScalaByExample"--seeResources):Listing1.rational.scalaclassRational(n:Int,d:I

7、nt){privatedefgcd(x:Int,y:Int):Int={if(x==0)yelseif(x<0)gcd(-x,y)elseif(y<0)-gcd(x,-y)-22-elsegcd(y%x,x)}privatevalg=gcd(n,d)valnumer:Int=n/gvaldenom:Int=d/gdef+(that:Rational)=newRational(numer*that.denom+that.numer*denom,denom*that.denom)def-(that:Rational)=newRational(num

8、er*that.denom-that.numer*denom,denom*that.denom)def*(that:Rational)=newRati

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。