PackageCom.hanqi.lianxi;ImportJava.util.Scanner; Public classStartwith {//write a method of judgment similar to Startwith Public Static voidMain (string[] args) {//start by defining a string as followsString str = "FGHKLDRT"; //We are prompted to enter a string to determine if the input string is the beginning of a string that was just definedScanner sc =NewScanner (system.in); System.out.println ("Please enter the beginning of the string you think"); String a=Sc.nextline (); //using IndexOf to determine whether the index number of the string we entered is 0, or 0, it is the beginning, otherwise it is not. ints =Str.indexof (a); if(s==0) {System.out.println ("You entered the beginning of the string str"); } Else{System.out.println ("You are not entering the beginning of the string str"); } }}
Write a method of judgment similar to Startwith