StringBuilder append ua haujlwm li cas?
StringBuilder append ua haujlwm li cas?

Video: StringBuilder append ua haujlwm li cas?

Video: StringBuilder append ua haujlwm li cas?
Video: Java для начинающих. Урок 23: StringBuilder 2024, Kaum ib hlis
Anonim

StringBuilder . ntxiv (String str) txoj kev ntxiv txoj hlua uas tau teev tseg rau qhov cim ua ntu zus. Cov cwj pwm ntawm txoj hlua sib cav yog ntxiv , nyob rau hauv kev txiav txim, nce qhov ntev ntawm qhov sib lawv liag los ntawm qhov ntev ntawm kev sib cav.

Tsis tas li ntawd, dab tsi ntxiv hauv StringBuilder?

java.lang. StringBuilder . ntxiv () txoj kev siv rau ntxiv txoj hlua sawv cev ntawm someargument rau lub sequence.java.lang. StringBuilder . ntxiv (char a): Qhov no yog txoj hauv kev aninbuilt hauv Java uas yog siv rau ntxiv lub stringrepresentation ntawm lub char sib cav rau qhov muabsequence.

Qhov thib ob, dab tsi ntxiv hauv Java txhais tau li cas? Cov ntxiv () txoj kev feem ntau hu ua thaum lub + tus neeg teb xov tooj siv rau ntawm cov khoom siv hlua. Java cia li hloov cov kev hloov kho rau ib qho piv txwv String rau hauv kev ua haujlwm zoo ib yam li StringBuffer piv txwv. Yog li ntawd, ib tug concatenation invokes ntxiv () ntawm ib qho khoom siv StringBuffer.

Kuj nug, StringBuilder ua haujlwm li cas?

StringBuilder cov khoom zoo li String khoom, tshwj tsis yog tias lawv tuaj yeem hloov kho. Sab hauv, cov khoom no raug kho zoo li qhov sib txawv-ntev arrays uas muaj cov kab ke ntawm cov cim. Piv txwv li, yog tias koj xav tau concatenate ntau cov hlua, ntxiv rau a StringBuilder yam khoom siv tau ntau dua.

Dab tsi yog kev siv append hauv Python?

Cov ntxiv () txoj kev ntxiv ib yam khoom mus rau qhov kawg ntawm daim ntawv teev npe. Cov ntxiv () txoj kev ntxiv ib yam khoom rau cov npe uas twb muaj lawm. Nws tsis rov qab daim ntawv teev npe tshiab; es nws hloov daim ntawv teev thawj.

Pom zoo: