Home  >  Article  >  类库下载  >  JAVA Basics String Basic Operations

JAVA Basics String Basic Operations

高洛峰
高洛峰Original
2016-10-19 09:28:261453browse

String str = "str";

str.length(); //3 Returns the length of the string

str.indexOf("s"); //0 Returns the index of s starting from 0; if not, returns -1

str.trim(); //"str" ​​Remove the spaces before and after str

str.substring(0,1); //"s" includes the beginning but not the end

str.charAt(0); // 's' Get the 0th character

str.startsWith("s") //true Whether it starts with s

str.endsWith("r") //true Whether it ends with r

str.toLowerCase() / /Convert all str to lowercase

str.toUpperCase() //Convert all str to uppercase

str.valueOf() //Convert the parameters brought in into string


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Java reflectionNext article:Java reflection