List of methods used when manipulating strings

This is Yuhei.

A list of each method used to change or move the string contents.

equals This method is used to check if the contents of strings variables are equal.

Unlike integer comparisons of basic data types, when using equals, it is a string comparison of reference data types.

equalslgnoreCase

This method is used to check if the contents are equal without being case sensitive.

The equals method also distinguishes between uppercase and lowercase when examining the contents, but this method allows you to inspect it without distinction.

lengh

Check the length of the string.

The length is the number of characters, not the number of bytes.

For example, in the following case, the result is 9.

String rong= new String("Good morning");

System.out.println(rong.length());

isEmpty

Checks if the string is empty.

In contrast to the previous length, which checks the number of characters, this method checks whether the contents of the string variable are empty.

"Empty state" is a state where there is nothing in the character string. In other words, the character string = ””.

String str = "";
 
if(str.isEmpty()){
   System.out.println("The contents of the str method are empty");
  } else {
    System.out.println("The contents of the str method are not empty");
}

The above code checks if the contents of the variable str are empty and uses an if statement to determine what the result will be.

Summary

Methods for manipulating and examining strings are rarely used by fledgling people,

Keeping in mind is useful when studying later.

that's all.

Recommended Posts

List of methods used when manipulating strings
List of methods used in PAIZA D rank
A collection of methods often used when manipulating time with TimeWithZone of Rails
Manipulating Java strings
[Ruby] Methods that can be used with strings
List of things I used without understanding well: Ruby
List of frequently used Java instructions (for beginners and beginners)
List of beginners (List) memo
[Docker] List of errors that occurred when building the environment