Yuav ua li cas koj xyuas yog hais tias ib lo lus nyob rau hauv cov ntaub ntawv Java?
Yuav ua li cas koj xyuas yog hais tias ib lo lus nyob rau hauv cov ntaub ntawv Java?

Video: Yuav ua li cas koj xyuas yog hais tias ib lo lus nyob rau hauv cov ntaub ntawv Java?

Video: Yuav ua li cas koj xyuas yog hais tias ib lo lus nyob rau hauv cov ntaub ntawv Java?
Video: yuav coj li cas kom luag nyiam 2024, Tej zaum
Anonim

Java Kev Tshawb Nrhiav rau ib muab lus hauv a Cov ntaub ntawv

Kauj Ruam 1: Ua ntej lus array. Kauj ruam 2: Tsim ib qho khoom rau FileReader thiab BufferedReader. Kauj ruam 5: Siv equals() method cov ntaub ntawv yog piv nrog tus muab lus thiab tus suav ntxiv. Kauj Ruam 6: Cov suav qhia lus tshwm sim los tsis nyob rau hauv cov ntaub ntawv.

Ib yam li ntawd, koj tuaj yeem nug, koj yuav kuaj xyuas li cas yog tias ib txoj hlua muaj lo lus Java?

Koj siv tau muaj (), indexOf() thiab lastIndexOf() txoj kev rau kuaj yog tias ib Txoj hlua muaj lwm Txoj hlua hauv Java los tsis. Yog ib txoj hlua muaj lwm Txoj hlua ces nws hu ua substring. Txoj kev indexOf() txais a Txoj hlua thiab rov pib txoj hauj lwm ntawm lub hlua if nws muaj, txwv tsis pub nws yuav rov qab -1.

Kuj Paub, Kuv yuav tshawb cov ntaub ntawv li cas rau ib lo lus? Yuav Ua Li Cas Tshawb Nrhiav cov lus hauv cov ntaub ntawv ntawm Windows 7

  1. Qhib windows explorer.
  2. Siv cov ntawv qhia zaub mov sab laug xaiv lub nplaub tshev los tshawb hauv.
  3. Nrhiav lub npov tshawb nrhiav nyob rau sab xis sab xis ntawm lub qhov rais explorer.
  4. Hauv lub thawv tshawb nrhiav cov ntsiab lus: ua raws li lo lus lossis kab lus koj tab tom nrhiav.(xws li cov ntsiab lus: koj lo lus)

Tsis tas li ntawd, koj tshawb nrhiav lo lus hauv Java li cas?

  1. Public class SearchStringEmp {
  2. public static void main(String args) {
  3. String strOrig = "Nyob zoo cov neeg nyeem";
  4. int intIndex = strOrig. indexOf("Nyob zoo");
  5. if(intIndex == - 1) {
  6. println("Nyob zoo tsis pom");
  7. } lwm {
  8. println("Found Hello at index"+ intIndex);

Kuv yuav nrhiav tau ib lo lus hauv kab C# li cas?

Rau nrhiav qhov tshwm sim thawj zaug lossis zaum kawg ntawm tus cwj pwm hauv tus txoj hlua : Siv a txoj hlua variable type int index = str. IndexOf(@""); qhov twg index yog qhov sib txawv uas yuav khaws qhov zero-raws li txoj hauj lwm ntawm tus cwj pwm hauv tus txoj hlua , str yog qhov sib txawv uas koj xav tshawb, thiab @"" yog qhov txoj hlua koj tab tom nrhiav.

Pom zoo: