<>char type

* stay Java in char(2 Bytes ) Type describes UTF-16 A unit of code in coding , Unless you really have to deal with it UTF-16 Code unit , It is best to treat strings as abstract data types
<> character string (String)(StringBuffer and StringBuilder To be added )

*
Java That's the string Unicode Character sequence ,Java There is no built-in string type , It's about standards Java A predefined class is provided in the library , be called “String”, Its instances are enclosed in double quotation marks
for example String e = " "; // An empty string String greeting = "Hello"; <>String Common methods in computer
* substring()
effect : Extract a substring from a larger string
for example : String greeting = "Hello"; String s = greeting.substring(0,3);
// After calling the method ,s="Hel", Only the location is extracted 3 previous , Namely (0,1,2)( Excluding location 3) Of , Its length is also very easy to calculate ,len=3-0=3.
* “+” Splicing

Java Language allowed “+” Join two strings , It should be noted that , If it is a string and non string connection , The latter is converted to a string ( stay Java in , Any string can be converted to a string )
for example :
example 1. Common splicing
String expletive = "Expletive"; String PGL3 = "deleted"; String message =
expletive+ PGL3; //message = Expletivedeleted
example 2. String splicing with other types
int a = 13; String name = "name" + a; // The results are as follows "name13"
example 2 The feature of is applied to the output statement , We often use it

*
equals()
effect : Can be used to detect whether two strings are equal ( content ), For example, expressions :

s.equal(t)

If string s And string t equal , Then return true, Otherwise, return false.
be careful : Don't use it == Detects whether two strings are equal , This operator can only detect whether two strings are placed in the same position

*
length()
effect : Returns the length of the string
String greeting = "Hello"; int n = greeting.length(); // Count Reg 5
image String.charAt(int index), The unit of code that can be returned to that location ,String There are many useful ways , For more information, please check API

Technology