Java programming: find the length of a string, using the keyboard arbitrary input a string, output the length of the string, (such as a keyboard input: 123 abd, output: string length is 6)
CodePudding user response:
All the things will be Posting for help, do not recommend to knock code yo, the baidu, a lot of casually
CodePudding user response:
reference 1st floor a584257442 response: all the things will be Posting for help and is not recommended to knock code yo, a casual baidu a lot of Does not meet the requirements, baidu, no find the right, CodePudding user response:
references came on the second floor if memories "of dye dust rain response: Quote: refer to 1st floor a584257442 response: all the things will be Posting for help and is not recommended to knock code yo, a casual baidu a lot of Does not meet the requirements, baidu, no find the right, Too simple, isn't it? Estimated net all nobody will ask, foundation of the foundation, brothers, Public class test3 { Public static void main (String [] args) { //TODO Auto - generated method stub Scanner sc=new Scanner(System.in); System. The out. Println (" please enter a string "); String STR=sc. NextLine (); System. The out. Println (" input string length is: "+ STR. The length ()); } } CodePudding user response:
Answer upstairs in the name of the class on a line and a impore Java. Util. Scanner; CodePudding user response:
import Java. Util. Scanner; /* Java programming: find the length of a string, using the keyboard arbitrary input a string, output the length of the string, (such as a keyboard input: 123 abd, output: string length is 6) */ Public class Test01 { Public static void main (String [] args) { Scanner sc=new Scanner (System. In); System. The out. Println (" please input string: "); System. The out. Println (" length is: "+ sc. Next (). The length ()); } } CodePudding user response:
Put the String assigned to a variable of type String (STR), then output the variable value of length: System. Out. The println (STR) length ());