Skip to content

Commit f4068ca

Browse files
committed
added strings in java
1 parent c943734 commit f4068ca

File tree

5 files changed

+113
-2
lines changed

5 files changed

+113
-2
lines changed

C/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@
5252
* DYNAMIC ARRAY
5353
* LINKED
5454

55+
#### TREES
56+
57+
* BINARY TREE
58+
* GENERIC TREES
59+
* THREADED BINARY TREE
60+
* XOR TREES
61+
* BINARY SEARCH TREE
62+
* AVL TREES
63+
* RED BLACK TREES
64+
* SPLAY TREES
65+
* AUGMENTED TREES
66+
* SCAPEGOAT TREES
67+
* INTERVAL TREES
68+
* HEAP TREE
69+
5570
#### HEAPS
5671

5772
* [1D ARRAYS USING HEAPS](Data-Structures/HEAPS/dynamicarray.c)
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
public class Strings
2+
{
3+
public static void main(String[] args)
4+
{
5+
/*USAGE OF STRING CLASS IN JAVA*/
6+
String trial = "Hello World this is github";
7+
8+
System.out.println("string:\t" + trial);
9+
System.out.println();
10+
11+
System.out.println("METHODS IN STRING CLASS");
12+
13+
//charAt()
14+
System.out.println("charAt(3):\t\t\t" + trial.charAt(3));
15+
16+
//indexOf()
17+
System.out.println("indexOf('o'):\t\t\t" + trial.indexOf('o'));
18+
System.out.println("indexOf('o',3):\t\t\t" + trial.indexOf('o',3));
19+
System.out.println("indexOf(\"this\"):\t\t" + trial.indexOf("this"));
20+
System.out.println("indexOf(\"this\",3):\t\t" + trial.indexOf("this",3));
21+
22+
//lastIndexOf()
23+
System.out.println("lastIndexOf('o'):\t\t" + trial.lastIndexOf('o'));
24+
System.out.println("lastIndexOf('o',3):\t\t" + trial.lastIndexOf('o',3));
25+
System.out.println("lastIndexOf(\"this\"):\t\t" + trial.lastIndexOf("this"));
26+
System.out.println("lastIndexOf(\"this\",4):\t\t" + trial.lastIndexOf("this",4));
27+
28+
//length()
29+
System.out.println("length():\t\t\t" + trial.length());
30+
31+
//substring()
32+
System.out.println("substring(1):\t\t\t" + trial.substring(1));
33+
System.out.println("substring(3,5):\t\t\t" + trial.substring(3,5));
34+
35+
//replace()
36+
System.out.println("replace('a','b'):\t\t" + trial.replace('a','b'));
37+
System.out.println("replace(\"Hello\",\"world\"):\t" + trial.replace("Hello","world"));
38+
39+
//concat()
40+
System.out.println("concat(\" Hello World\"):\t\t" + trial.concat(" Hello World"));
41+
42+
//equals()
43+
System.out.println("equals(\"Hello World this is github\"):\t" + trial.equals("hello wotld a bac a"));
44+
45+
//toUpperCase()
46+
System.out.println("toUpperCase():\t\t\t" + trial.toUpperCase());
47+
48+
//toLowerCase()
49+
System.out.println("toLowerCase():\t\t\t" + trial.toLowerCase());
50+
}
51+
}

Java/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
* [three dimensional array](Data-Structures/ARRAYS/threeDarray.java)
1414
* [four dimensional array](Data-Structures/ARRAYS/fourDarray.java)
1515

16+
#### STRING
17+
18+
* [implementation with methods](Data-Structures/STRING/Strings.java)
19+
1620
#### LISTS
1721

1822
* LINKED LIST
@@ -38,6 +42,10 @@
3842
* [Stack class](Data-Structures/STACKS/INBUILT-STACK/Stacks.java)
3943
* MISC STACKS
4044

45+
#### QUEUES
46+
47+
#### TREES
48+
4149
### :rocket: DYNAMIC PROGRAMMING
4250

4351
### :rocket: MISC

datastructures.md

+7
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ Indexer for Data Structures Lover
6363
* implementation
6464
* [C](C/Data-Structures/ARRAYS/jaggedarray.c)
6565

66+
### :octocat: STRING
67+
68+
* blog
69+
* docs
70+
* implementation
71+
* [JAVA](Java/Data-Structures/STRING/Strings.java)
72+
6673
### :octocat: LISTS
6774

6875
#### SINGLE

docs/complexity.md

+32-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ This page contains the complexities of different algorithms in this repository.
6161
* ARRAY CLASS IN C++
6262
* [MISC ARRAYS](#misc-arrays)
6363
* [JAGGED ARRAY](#jagged-array)
64+
* [STRING](#string)
65+
* [Strings in JAVA](#strings-in-java)
6466
* [LISTS](#lists)
6567
* SINGLE
6668
* [SINGULAR LINKED LIST](#singular-linked-list-having-head-and-next)
@@ -99,11 +101,23 @@ This page contains the complexities of different algorithms in this repository.
99101
* HEAPED PRIORITY QUEUE
100102
* HASHTABLE
101103
* TREES
104+
* BINARY TREE
105+
* GENERIC TREES
106+
* THREADED BINARY TREE
107+
* XOR TREES
108+
* BINARY SEARCH TREE
109+
* AVL TREES
110+
* RED BLACK TREES
111+
* SPLAY TREES
112+
* AUGMENTED TREES
113+
* SCAPEGOAT TREES
114+
* INTERVAL TREES
115+
* HEAP TREE
116+
* GRAPHS
102117
* HEAPS
103118
* [DYNAMIC 1D ARRAY](#dynamic-1d-arrays-(CC++))
104119
* [DYNAMIC 2D ARRAY](#dynamic-2d-arrays-(CC++))
105120
* [DYNAMIC 3D ARRAY](#dynamic-3d-arrays-(CC++))
106-
* GRAPHS
107121
* BLOCKCHAIN
108122

109123
## ALGORITHMS
@@ -122,7 +136,7 @@ This page contains the complexities of different algorithms in this repository.
122136
#### :rocket: SORTING
123137

124138
SNo. | Algorithm | Order of complexity O(n) | Type of Complexity | Stable/Unstable Sort | In Place Algorithm | Space Complexity
125-
---- | --------- | ------------------------ | ------------------ | -------------------- | ------------------ | ----------------
139+
---- | --------- Data-Structures/STRING/Strings.java| ------------------------ | ------------------ | -------------------- | ------------------ | ----------------
126140
1 | Bubble Sort | O(n^2) | Quadratic | Stable / Can be Unstable** | :heavy_check_mark: | O(1)
127141
2 | Selection Sort | O(n^2) | Quadratic | Unstable | :heavy_check_mark: | O(1)
128142
3 | Insertion Sort | O(n^2) | Quadratic | Stable | :heavy_check_mark: | O(1)
@@ -273,6 +287,22 @@ This page contains the complexities of different algorithms in this repository.
273287

274288
##### ARRAY CLASS IN C++
275289

290+
### STRING
291+
292+
#### Strings in JAVA
293+
294+
SNo. | Methods | Order of complexity O(n) | Type of Complexity
295+
1 | char charAt() | O(1) | Constant
296+
2 | int indexOf() | O(n) | Linear
297+
3 | lastIndexOf() | O(n) | Linear
298+
4 | int length() | O(1) | Constant
299+
5 | substring() | O(n) | Linear
300+
6 | replace() | O(n) | Linear
301+
7 | concat(str) | O(n^2) | Quadratic
302+
8 | equals(str) | O(n) | Linear
303+
9 | toUpperCase() | O(n) | Linear
304+
10 | toLowerCase() | O(n) | Linear
305+
276306
### LISTS
277307

278308
#### SINGLE

0 commit comments

Comments
 (0)