Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/java-course.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.rinftech.animals;

import jdk.nashorn.internal.codegen.CompilerConstants;
//import jdk.nashorn.internal.codegen.CompilerConstants;

import java.util.Objects;

Expand Down
29 changes: 29 additions & 0 deletions JavaCourse/src/main/java/com/rinftech/collections/Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.rinftech.collections;

public class Employee extends Person {
private Integer employeeId;

private String title;


public Employee() {
}

public Employee(Integer employeeId, String title) {
this.employeeId = employeeId;
this.title = title;
}

public Integer getEmployeeId() {
return employeeId;
}

public String getTitle() {
return title;
}

@Override
public String getLastName() {
return super.getLastName() + " is " + this.getTitle();
}
}
24 changes: 24 additions & 0 deletions JavaCourse/src/main/java/com/rinftech/collections/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.rinftech.collections;

public class Person {

private String firstName;
private String lastName;

public Person() {

}

public Person(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}

public String getFirstName() {
return firstName;
}

public String getLastName() {
return lastName;
}
}
38 changes: 38 additions & 0 deletions JavaCourse/src/main/java/com/rinftech/collections/Probl10.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.rinftech.collections;

import java.util.*;

public class Probl10 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
try {
// List<String> array = readArray(scanner);
// String color = scanner.nextLine();
List<String> array = new ArrayList<>(Arrays.asList(
"eat", "tea", "tan", "ate", "nat", "bat", "listen", "silent", "enlist", "hello", "world", "dlrow"
));
Map<String, List<String>> result = groupAnagrams(array);
System.out.println(result.toString());
} catch (Exception e) {
System.out.println(e);
} finally {
scanner.close();
}
}

public static Map<String, List<String>> groupAnagrams(List<String> words) {
Map<String, List<String>> anagramsMap = new HashMap<>();

for (String word : words) {
char[] chars = word.toCharArray();
Arrays.sort(chars);
String sortedWord = new String(chars);
if (!anagramsMap.containsKey(sortedWord)) {
anagramsMap.put(sortedWord, new ArrayList<>());
}
anagramsMap.get(sortedWord).add(word);
}

return anagramsMap;
}
}
47 changes: 47 additions & 0 deletions JavaCourse/src/main/java/com/rinftech/collections/Probl5.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.rinftech.collections;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Probl5 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
try {
List<String> firstArray = readArray(scanner);
List<String> secondArray = readArray(scanner);
List<String> result = findCommonElements(firstArray, secondArray);
System.out.println(result.toString());
}
catch (Exception e) {
System.out.println(e);
}
finally {
scanner.close();
}
}

public static List<String> readArray(Scanner scanner) {
System.out.print("Enter the size of the array: ");
int size = scanner.nextInt();
scanner.nextLine();
List<String> array = new ArrayList<>();
for (int i = 0; i < size; i++) {
System.out.print("Enter element " + (i + 1) + ": ");
array.add(scanner.nextLine());
}
return array;
}

public static List<String> findCommonElements(List<String> array1, List<String> array2) {
List<String> result = new ArrayList<>();
for (String element : array1) {
for (String element1 : array2) {
if (element.equals(element1)) {
result.add(element);
}
}
}
return result;
}
}
Loading