Java string

[Java string]

A memo of Java strings used in business. I used it during development, so I summarized it.

StringBuilder

StringBuilder class can be used after instantiation This is a class for performing character string operations.

In string concatenation, use the append method and the string you want to concatenate using the arguments.

When concatenating a large number of strings, you should try to use StringBuilder, which has the highest performance.

//Excerpt from some of the formats used in business

//Instance generation
StringBuilder sb = new StringBuilder();

//SQL generation
sb.append("SELECT");
sb.append("Sample");
sb.append("Sample2");
sb.append("Sample3");
sb.append("FROM");
sb.append("SampleTable");


//* Batch processing is performed 24 hours a day, 365 days a year, so it is used so that the processing speed does not slow down.

When using StringBuffer

When using threads, StringBuilder may cause problems. Instead, use the StringBuffer class.

I don't want to use StringBuilder in a multithreaded environment, so StringBuilder with good performance if thread safety is guaranteed. If thread safety is not guaranteed, use StringBuffer instead.

The basic writing style is almost the same.

Digression

Many of the seniors in the company have been using Java for about 20 years in business, so I think that I am very fortunate because there are many people like mentors close to me as a Java beginner.

Recommended Posts

Java string
[Java] String padding
Java string processing
Split string (Java)
[Java] String comparison and && and ||
Java string multiple replacement
[Note] Java: String search
[Note] Java: String survey
Java
About Java String class
String
Java
Java inflexible String class substring
Reflection on Java string manipulation
[Java] About String and StringBuilder
[Java] Speed comparison of string concatenation
Java learning (0)
Studying Java ―― 3
[Java] array
[Java] Annotation
[Java] Module
Java array
Java tips, tips
Java methods
Java method
java (constructor)
Java array
[Java] ArrayDeque
java (override)
java (method)
String puzzle
Various methods of Java String class
Java Day 2018
java (array)
Java static
Java serialization
java beginner 4
JAVA paid
Studying Java ―― 4
Java (set)
java shellsort
[Java] compareTo
Studying Java -5
java reflexes
java (interface)
Java memorandum
☾ Java / Collection
Java array
Studying Java ―― 1
[Java] Array
[Java] Polymorphism
Studying Java # 0
Java review
java framework
Java features
[Java] Inheritance
FastScanner Java
Java features
java beginner 3
Java memo
java (encapsulation)