Skip to content

Commit

Permalink
added strings in java
Browse files Browse the repository at this point in the history
  • Loading branch information
GauravWalia19 committed Dec 21, 2018
1 parent c943734 commit f4068ca
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 2 deletions.
15 changes: 15 additions & 0 deletions C/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@
* DYNAMIC ARRAY
* LINKED

#### TREES

* BINARY TREE
* GENERIC TREES
* THREADED BINARY TREE
* XOR TREES
* BINARY SEARCH TREE
* AVL TREES
* RED BLACK TREES
* SPLAY TREES
* AUGMENTED TREES
* SCAPEGOAT TREES
* INTERVAL TREES
* HEAP TREE

#### HEAPS

* [1D ARRAYS USING HEAPS](Data-Structures/HEAPS/dynamicarray.c)
Expand Down
51 changes: 51 additions & 0 deletions Java/Data-Structures/STRING/Strings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
public class Strings
{
public static void main(String[] args)
{
/*USAGE OF STRING CLASS IN JAVA*/
String trial = "Hello World this is github";

System.out.println("string:\t" + trial);
System.out.println();

System.out.println("METHODS IN STRING CLASS");

//charAt()
System.out.println("charAt(3):\t\t\t" + trial.charAt(3));

//indexOf()
System.out.println("indexOf('o'):\t\t\t" + trial.indexOf('o'));
System.out.println("indexOf('o',3):\t\t\t" + trial.indexOf('o',3));
System.out.println("indexOf(\"this\"):\t\t" + trial.indexOf("this"));
System.out.println("indexOf(\"this\",3):\t\t" + trial.indexOf("this",3));

//lastIndexOf()
System.out.println("lastIndexOf('o'):\t\t" + trial.lastIndexOf('o'));
System.out.println("lastIndexOf('o',3):\t\t" + trial.lastIndexOf('o',3));
System.out.println("lastIndexOf(\"this\"):\t\t" + trial.lastIndexOf("this"));
System.out.println("lastIndexOf(\"this\",4):\t\t" + trial.lastIndexOf("this",4));

//length()
System.out.println("length():\t\t\t" + trial.length());

//substring()
System.out.println("substring(1):\t\t\t" + trial.substring(1));
System.out.println("substring(3,5):\t\t\t" + trial.substring(3,5));

//replace()
System.out.println("replace('a','b'):\t\t" + trial.replace('a','b'));
System.out.println("replace(\"Hello\",\"world\"):\t" + trial.replace("Hello","world"));

//concat()
System.out.println("concat(\" Hello World\"):\t\t" + trial.concat(" Hello World"));

//equals()
System.out.println("equals(\"Hello World this is github\"):\t" + trial.equals("hello wotld a bac a"));

//toUpperCase()
System.out.println("toUpperCase():\t\t\t" + trial.toUpperCase());

//toLowerCase()
System.out.println("toLowerCase():\t\t\t" + trial.toLowerCase());
}
}
8 changes: 8 additions & 0 deletions Java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
* [three dimensional array](Data-Structures/ARRAYS/threeDarray.java)
* [four dimensional array](Data-Structures/ARRAYS/fourDarray.java)

#### STRING

* [implementation with methods](Data-Structures/STRING/Strings.java)

#### LISTS

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

#### QUEUES

#### TREES

### :rocket: DYNAMIC PROGRAMMING

### :rocket: MISC
Expand Down
7 changes: 7 additions & 0 deletions datastructures.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ Indexer for Data Structures Lover
* implementation
* [C](C/Data-Structures/ARRAYS/jaggedarray.c)

### :octocat: STRING

* blog
* docs
* implementation
* [JAVA](Java/Data-Structures/STRING/Strings.java)

### :octocat: LISTS

#### SINGLE
Expand Down
34 changes: 32 additions & 2 deletions docs/complexity.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ This page contains the complexities of different algorithms in this repository.
* ARRAY CLASS IN C++
* [MISC ARRAYS](#misc-arrays)
* [JAGGED ARRAY](#jagged-array)
* [STRING](#string)
* [Strings in JAVA](#strings-in-java)
* [LISTS](#lists)
* SINGLE
* [SINGULAR LINKED LIST](#singular-linked-list-having-head-and-next)
Expand Down Expand Up @@ -99,11 +101,23 @@ This page contains the complexities of different algorithms in this repository.
* HEAPED PRIORITY QUEUE
* HASHTABLE
* TREES
* BINARY TREE
* GENERIC TREES
* THREADED BINARY TREE
* XOR TREES
* BINARY SEARCH TREE
* AVL TREES
* RED BLACK TREES
* SPLAY TREES
* AUGMENTED TREES
* SCAPEGOAT TREES
* INTERVAL TREES
* HEAP TREE
* GRAPHS
* HEAPS
* [DYNAMIC 1D ARRAY](#dynamic-1d-arrays-(CC++))
* [DYNAMIC 2D ARRAY](#dynamic-2d-arrays-(CC++))
* [DYNAMIC 3D ARRAY](#dynamic-3d-arrays-(CC++))
* GRAPHS
* BLOCKCHAIN

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

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

##### ARRAY CLASS IN C++

### STRING

#### Strings in JAVA

SNo. | Methods | Order of complexity O(n) | Type of Complexity
1 | char charAt() | O(1) | Constant
2 | int indexOf() | O(n) | Linear
3 | lastIndexOf() | O(n) | Linear
4 | int length() | O(1) | Constant
5 | substring() | O(n) | Linear
6 | replace() | O(n) | Linear
7 | concat(str) | O(n^2) | Quadratic
8 | equals(str) | O(n) | Linear
9 | toUpperCase() | O(n) | Linear
10 | toLowerCase() | O(n) | Linear

### LISTS

#### SINGLE
Expand Down

0 comments on commit f4068ca

Please sign in to comment.