CIT590 From Python to Java

Urnlngtv ytmotpitneaie es i 0 le f x sseurnlzr

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: i x<0 f : pit'eaie rn ngtv' ei x= 0 lf =: pit'eo rn zr' es: le pit'oiie rn pstv' i ( <0 { fx ) Sse.u.rnl(ngtv"; ytmotpitn"eaie) }es i ( = 0 { le f x = ) Sse.u.rnl(zr"; ytmotpitn"eo) }es { le Sse.u.rnl(pstv"; ytmotpitn"oiie) } frii rne0 lnls): o n ag(, e(it) pitls rn iti fr(n i=0 i<arylnt;i+ { o it ; ra.egh +) Sse.u.rnl(ra; ytmotpitnaryi) } frvlei ls: o au n it pitvle rn(au) fr(n vle:ary { o it au ra) Sse.u.rnl(au) ytmotpitnvle; } No equivalent. d{ o wr =sanrnx(; od cne.et) wie( wr.qas"n") hl ! odeul(ed); No equivalent. sic(nwr { wthase) cs 1 ae : Sse.u.rnl(ys) ytmotpitn"e"; bek ra; cs 2 ae : Sse.u.rnl(n"; ytmotpitn"o) bek ra; dfut eal: Sse.u.rnl(ukon) ytmotpitn"nnw"; } rieVlero,'a vle as auErr Bd au' trwnwAiheiEcpin"a vle) ho e rtmtcxeto(Bd au"; ty r: dSmtig) ooehn( ecp Vlero,mg xet auErr s: pitmg rn s ecp: xet pit'oehn wn wog rn Smtig et rn' fnly ial: awyDTi( lasohs) ty{ r dSmtig) ooehn(; } cth(rtmtcxeto e { ac AiheiEcpin ) Sse.u.rnl(.eMsae); ytmotpitnegtesg() } cth(xeto e { ac Ecpin ) epittcTae) .rnSakrc(; } fnly{ ial awyDTi(; lasohs) } asr x>0 set asr x>0 set ; bek ra bek ra; cniu otne cniu; otne ps as {} rtr eun rtr; eun www.cis.upenn.edu/~ matuszek/cit590- 2013/Pag es/python- to- java.html 4/6 3/13/13 CIT590 Fr om Python to Java rtr a+b eun rtr a+b eun ; M ethods and constructors Java has no "functions," only methods. A method may have an optional access modifier, and must have a return type. If the method doesn't return anything, the return type is v i . The type of each parameter must be specified. The syntax of a method declaration is: od acs rtrTp mtoNm(yeprmtr .. tp prmtr { ces eunye ehdaetp aaee, ., ye aaee) .. . } Example: /* * *Fnsterwi tecd bokcnann tegvn id h o n h oe lc otiig h ie *caatr hrce. * [email protected] bokTearyt b sace. prm lc h ra o e erhd [email protected] c Tecaatrt sac fr prm h h hrce o erh o. [email protected] tecaatr(r- i ntfud. rtr h o ne f h hrce o 1 f o on) * / itfnRwca[[ bok ca c){ n ido(hr]] lc, hr h fr(n i=0 i<5 i+ { o it ; ; +) fr(n j=0 j&l...
View Full Document

This document was uploaded on 02/02/2014.

Ask a homework question - tutors are online