- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.java
More file actions
Latest commit
60 lines (34 loc) · 1.28 KB
/
Copy pathstring.java
File metadata and controls
60 lines (34 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
Strings are immutable in Java
when you are appending strings
watch out for the cost of operations
String is backed by a char array
*/
[java]
{
Stringname = "Value";
name.toLowerCase();
name.toUpperCase();//very self explanatory
name.substring(beginning , end-noninclusive)
name.charAt(index);
name.replace(StringtoBeErased, StringrePlacement);
}[java]
// You can just add/append to the string same way you add/append to literals
//Using String builder because string is immutable
-----------------------------------------------------------
StringBuilderUsage
-----------------------------------------------------------
- Notthebestforconcurrencyproblems
- Noguranteeofsynchronization - notsafeformulti-threading
[java]{
StringBuildername = newStringBuilder(intcapcity);
StringBuildername = newStringBuilder(Stringstr);
name.append();//append given argument to the end of the invoked object
name.insert(Integerindex, StringtoBeInserted);
//insert behind given position
name.replace(Integerindex, StringrePlacement);
name.reverse();//revese the given string
name.delete();//deletes from the specific end/beginning index
}
//the cost of operation for trimming a string
//what the fuck is regex and how do you split string?