Skip to content

Commit

Permalink
feat(practice): .compareTo String class
Browse files Browse the repository at this point in the history
  • Loading branch information
101zh committed Sep 26, 2023
1 parent 69ee5e0 commit c173687
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"configurations": [
{
"type": "java",
"name": "Test",
"request": "launch",
"mainClass": "Test",
"projectName": "my-app"
},
{
"type": "java",
"name": "Launch App",
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/CompareToTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Just some practice with .compareTo method of String class

import org.junit.Test;

public class CompareToTest {
@Test
public void main(String[] args) {
String a = "gene";
String b = "deter";
String c = "remedy";
String d = "chocolate";
String e = "supress";

String[] o = { a, b, c, d, e };

for (int i = 0; i<5; i++){
for (int j=0; j<5; j++){
System.out.println(o[i].compareTo(o[j]));
}
}
// 0
// positive
// negative
// etc.

}
}

0 comments on commit c173687

Please sign in to comment.