From d66c6108035c74acc027e4a88838719dc272531e Mon Sep 17 00:00:00 2001 From: Anugautam1998 Date: Sat, 30 Sep 2023 18:56:50 +0530 Subject: [PATCH 1/2] Anu | JDBL-58 | Assignment Stream and maven projects --- .../globaldb/.gitignore | 36 +++++++ .../globaldb/pom.xml | 61 +++++++++++ .../db/globaldb/connection/DbConnection.java | 5 + .../example/db/globaldb/connection/Main.java | 7 ++ .../mongodb/.gitignore | 37 +++++++ .../mongodb/pom.xml | 70 ++++++++++++ .../java/com/example/nosql/mongodb/Main.java | 7 ++ .../com/example/nosql/mongodb/MongoDB.java | 10 ++ .../src/main/resources/application.properties | 1 + .../mongodb/MongodbApplicationTests.java | 13 +++ .../mysql/.gitignore | 37 +++++++ .../mysql/pom.xml | 66 ++++++++++++ .../src/main/java/com/example/sql/Main.java | 9 ++ .../src/main/java/com/example/sql/SqlDB.java | 11 ++ .../src/com/Main.java | 69 ++++++++++++ .../src/com/Person/AgeCalculator.java | 100 ++++++++++++++++++ .../src/com/Person/People.java | 57 ++++++++++ .../src/com/Person/RandomGenerator.java | 15 +++ 18 files changed, 611 insertions(+) create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/.gitignore create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/pom.xml create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/src/main/java/com/example/db/globaldb/connection/DbConnection.java create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/src/main/java/com/example/db/globaldb/connection/Main.java create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/.gitignore create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/pom.xml create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/main/java/com/example/nosql/mongodb/Main.java create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/main/java/com/example/nosql/mongodb/MongoDB.java create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/main/resources/application.properties create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/test/java/com/example/nosql/mongodb/MongodbApplicationTests.java create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/.gitignore create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/pom.xml create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/src/main/java/com/example/sql/Main.java create mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/src/main/java/com/example/sql/SqlDB.java create mode 100644 ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Main.java create mode 100644 ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Person/AgeCalculator.java create mode 100644 ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Person/People.java create mode 100644 ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Person/RandomGenerator.java diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/.gitignore b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/.gitignore new file mode 100644 index 0000000..8530a83 --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/.gitignore @@ -0,0 +1,36 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +.mvn +mvnw +mvnw.cmd + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/pom.xml b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/pom.xml new file mode 100644 index 0000000..39eb124 --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.1.4 + + + com.example.db + globaldb + 0.0.5-SNAPSHOT + globaldb + Demo project for Spring Boot + jar + + 11 + + + + org.springframework.boot + spring-boot-starter-web + + + org.apache.maven.plugins + maven-assembly-plugin + 3.4.2 + maven-plugin + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + jar-with-dependencies + + + + com.example.db.globaldb.connection.Main + + + + + + make-assembly + package + + single + + + + + + + + diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/src/main/java/com/example/db/globaldb/connection/DbConnection.java b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/src/main/java/com/example/db/globaldb/connection/DbConnection.java new file mode 100644 index 0000000..60ebb30 --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/src/main/java/com/example/db/globaldb/connection/DbConnection.java @@ -0,0 +1,5 @@ +package com.example.db.globaldb.connection; + +public abstract class DbConnection { + public abstract void connectToDB(String connectionUrl); +} diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/src/main/java/com/example/db/globaldb/connection/Main.java b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/src/main/java/com/example/db/globaldb/connection/Main.java new file mode 100644 index 0000000..fb945bc --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/globaldb/src/main/java/com/example/db/globaldb/connection/Main.java @@ -0,0 +1,7 @@ +package com.example.db.globaldb.connection; + +public class Main { + public static void main(String[] args) { + System.out.println("Hello"); + } +} diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/.gitignore b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/.gitignore new file mode 100644 index 0000000..69eef23 --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/.gitignore @@ -0,0 +1,37 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +.mvn +mvnw +mvnw.cmd + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/pom.xml b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/pom.xml new file mode 100644 index 0000000..3be95c9 --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/pom.xml @@ -0,0 +1,70 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.1.4 + + + com.example.nosql + mongodb + 0.0.1-SNAPSHOT + mongodb + Demo project for Spring Boot + + 17 + + + + org.springframework.boot + spring-boot-starter-web + + + org.apache.maven.plugins + maven-assembly-plugin + 3.4.2 + maven-plugin + + + com.example.db + globaldb + 0.0.5-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + jar-with-dependencies + + + + com.example.sql.Main + + + + + + make-assembly + package + + single + + + + + + + + diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/main/java/com/example/nosql/mongodb/Main.java b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/main/java/com/example/nosql/mongodb/Main.java new file mode 100644 index 0000000..f1139c6 --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/main/java/com/example/nosql/mongodb/Main.java @@ -0,0 +1,7 @@ +package com.example.nosql.mongodb; + +public class Main { + public static void main(String[] args) { + System.out.println("Hi"); + } +} diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/main/java/com/example/nosql/mongodb/MongoDB.java b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/main/java/com/example/nosql/mongodb/MongoDB.java new file mode 100644 index 0000000..f500bad --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/main/java/com/example/nosql/mongodb/MongoDB.java @@ -0,0 +1,10 @@ +package com.example.nosql.mongodb; + +import com.example.db.globaldb.connection.DbConnection; + +public class MongoDB extends DbConnection { + @Override + public void connectToDB(String connectionUrl) { + System.out.println("Connected"); + } +} diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/main/resources/application.properties b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/test/java/com/example/nosql/mongodb/MongodbApplicationTests.java b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/test/java/com/example/nosql/mongodb/MongodbApplicationTests.java new file mode 100644 index 0000000..af9d6b7 --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/test/java/com/example/nosql/mongodb/MongodbApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.nosql.mongodb; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class MongodbApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/.gitignore b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/.gitignore new file mode 100644 index 0000000..69eef23 --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/.gitignore @@ -0,0 +1,37 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +.mvn +mvnw +mvnw.cmd + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/pom.xml b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/pom.xml new file mode 100644 index 0000000..9adac5e --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/pom.xml @@ -0,0 +1,66 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.1.4 + + + com.example.sql + mysql + 0.0.1-SNAPSHOT + mysql + Demo project for Spring Boot + + 17 + + + + org.springframework.boot + spring-boot-starter-web + + + com.example.db + globaldb + 0.0.5-SNAPSHOT + + + org.apache.maven.plugins + maven-assembly-plugin + 3.4.2 + maven-plugin + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + jar-with-dependencies + + + + com.example.sql.Main + + + + + + make-assembly + package + + single + + + + + + + + + diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/src/main/java/com/example/sql/Main.java b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/src/main/java/com/example/sql/Main.java new file mode 100644 index 0000000..e588b6c --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/src/main/java/com/example/sql/Main.java @@ -0,0 +1,9 @@ +package com.example.sql; + +import org.springframework.boot.SpringApplication; + +public class Main { + public static void main(String[] args) { + SpringApplication.run(Main.class, args); + } +} diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/src/main/java/com/example/sql/SqlDB.java b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/src/main/java/com/example/sql/SqlDB.java new file mode 100644 index 0000000..8f51d50 --- /dev/null +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/src/main/java/com/example/sql/SqlDB.java @@ -0,0 +1,11 @@ +package com.example.sql; + +import com.example.db.globaldb.connection.DbConnection; + +class SqlDB extends DbConnection{ + + @Override + public void connectToDB(String connectionUrl) { + + } +} diff --git a/ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Main.java b/ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Main.java new file mode 100644 index 0000000..b0b4cbe --- /dev/null +++ b/ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Main.java @@ -0,0 +1,69 @@ +import Person.AgeCalculator; +import Person.People; +import Person.RandomGenerator; + +import java.util.ArrayList; +import java.util.List; + +public class Main { + public static void main(String[] args) { + List list = new ArrayList<>(); + list.add(new People("Anu",23,"Female","India")); + list.add(new People("Jenny",18,"Female","USA")); + list.add(new People("xyz",18,"Male","China")); + list.add(new People("NYC",25,"Female","China")); + list.add(new People("Terry",30,"Male","China")); + list.add(new People("Gautam",10,"Male","India")); + list.add(new People("hnk",12,"Male","USA")); + + //Printed the avg age of all the people + AgeCalculator age = new AgeCalculator(); + System.out.println("Average age of all people:"); + System.out.println(age.averageAge(list)); + System.out.println(); + + //Created a list of all the people who are either greater than 20 or contain any vowel in their name + System.out.println("List of people whose age is either greater than twenty or name contains any vowel:"); + AgeCalculator ageVowel = new AgeCalculator(); + ageVowel.ageGreaterThanTwentyOrNameContainsAnyVowel(list); + System.out.println(); + + //Created a list of people, sorted in ascending order on the basis of age, + // if age is the same then sort in descending order of name + System.out.println("List of people age in dec order:"); + AgeCalculator ageSort = new AgeCalculator(); + ageSort.peopleSortedOnBasisOfAge(list); + System.out.println(); + + //Created a map from this people list where the key is country name and + // value is count which means map will tell how many people live in a particular country + System.out.println("Created a map of people key as countryTheylive and value as number of people:"); + AgeCalculator map = new AgeCalculator(); + map.mapPeople(list); + System.out.println(); + + //Create a map which stores avg age of people per country + System.out.println("Created a map the stores avg age of people per country:"); + AgeCalculator map1 = new AgeCalculator(); + map1.mapAvgAge(list); + System.out.println(); + + //Printed the oldest person in every country + System.out.println("Oldest person in every country:"); + AgeCalculator old = new AgeCalculator(); + old.oldestPeople(list); + System.out.println(); + + //Printed the country with most people + System.out.println("Country with most people:"); + AgeCalculator most = new AgeCalculator(); + most.mostPeople(list); + System.out.println(); + + System.out.println("Random Numbers:"); + //Created a list of 20 random integers in the range 0-1000 + RandomGenerator r = new RandomGenerator(); + r.listOfInt(); + System.out.println(); + } +} diff --git a/ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Person/AgeCalculator.java b/ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Person/AgeCalculator.java new file mode 100644 index 0000000..93847be --- /dev/null +++ b/ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Person/AgeCalculator.java @@ -0,0 +1,100 @@ +package Person; + +import java.util.*; +import java.util.stream.Collectors; + +public class AgeCalculator { + public double averageAge(List list){ + return (list.stream().mapToDouble(x->x.getAge()).average().getAsDouble());//Average age + } + public void ageGreaterThanTwentyOrNameContainsAnyVowel(List list){ + List list1 = list.stream().filter(x ->x.getAge() > 20 || containsVowel(x.getName())).collect(Collectors.toList()); + list1.forEach(x->System.out.println(x.toString())); //age>20 or name contain any vowel + } + + private boolean containsVowel(String name) { // method for containsVowel + { + String vowels = "AEIOUaeiou"; + for (char c : name.toCharArray()) { + if (vowels.indexOf(c) != -1) { + return true; + } + } + return false; + } + } + public void peopleSortedOnBasisOfAge(List list){ + List list2 = list.stream().sorted(Comparator.comparingInt(People::getAge) + .thenComparing(Comparator.comparing(People::getName).reversed())).collect(Collectors.toList()); + //List of people on the basis of age sorted or if same age then on the basis of their name in dec order + list2.forEach(System.out::println); + //list.stream().map(People::getAge).sorted().collect(Collectors.toList()).forEach(x-> System.out.println(x.toString())); + + } + public void mapPeople(List list){ + Map countryCountMap = list.stream().collect(Collectors.groupingBy(People::getCountryTheyLive, Collectors.counting())); + System.out.println(countryCountMap);//Map of people key as country and value number of people in the particular country + } + public void mapAvgAge(List list){ + Map countryAvgAgeMap = list.stream() + .collect(Collectors.groupingBy(People::getCountryTheyLive, Collectors.averagingDouble(People::getAge))); + System.out.println(countryAvgAgeMap);//map which contains the avg age of people per country + } + public void oldestPeople(List list){ + // Create a map to group people by country + Map> peopleByCountry = new HashMap<>(); + for (People x : list) { + String country = x.getCountryTheyLive(); + peopleByCountry.putIfAbsent(country, new ArrayList<>()); + peopleByCountry.get(country).add(x); + } + // Create a map to store the oldest person by country + Map oldestByCountry = new HashMap<>(); + + for (Map.Entry> entry : peopleByCountry.entrySet()) { + String country = entry.getKey(); + List countryPeople = entry.getValue(); + + // Find the oldest person within the country's list + People oldestPerson = countryPeople.stream() + .max((p1, p2) -> Integer.compare(p1.getAge(), p2.getAge())) + .orElse(null); + + if (oldestPerson != null) { + oldestByCountry.put(country, oldestPerson); + } + } + + // Print the oldest person from each country + for (Map.Entry entry : oldestByCountry.entrySet()) { + String country = entry.getKey(); + People oldestPerson = entry.getValue(); + System.out.println("Oldest person in " + country + ": " + oldestPerson); + } + } + public void mostPeople(List list){ + Map countryCount = new HashMap<>(); + for (People x : list) { + String country = x.getCountryTheyLive(); + countryCount.put(country, countryCount.getOrDefault(country, 0) + 1); + } + // Find the country with the most people + String mostPopulatedCountry = ""; + int maxPopulation = 0; + + for (Map.Entry entry : countryCount.entrySet()) { + String country = entry.getKey(); + int population = entry.getValue(); + + if (population > maxPopulation) { + maxPopulation = population; + mostPopulatedCountry = country; + } + } + // Print the most populated country + System.out.println("The country with the most people is: " + mostPopulatedCountry); + } + + } + + diff --git a/ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Person/People.java b/ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Person/People.java new file mode 100644 index 0000000..186e058 --- /dev/null +++ b/ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Person/People.java @@ -0,0 +1,57 @@ +package Person; + +public class People { + private String name; + private Integer age; + private String gender; + private String countryTheyLive; + + public People(String name, int age, String gender, String countryTheyLive) { + this.name = name; + this.age = age; + this.gender = gender; + this.countryTheyLive = countryTheyLive; + } + + public String getName() { + return name; + } + + public Integer getAge() { + return age; + } + + public String getGender() { + return gender; + } + + public String getCountryTheyLive() { + return countryTheyLive; + } + + public void setName(String name) { + this.name = name; + } + + public void setAge(Integer age) { + this.age = age; + } + + public void setGender(String gender) { + this.gender = gender; + } + + public void setCountryTheyLive(String countryTheyLive) { + this.countryTheyLive = countryTheyLive; + } + + @Override + public String toString() { + return "People{" + + "name='" + name + '\'' + + ", age=" + age + + ", gender='" + gender + '\'' + + ", countryTheyLive='" + countryTheyLive + '\'' + + '}'; + } +} diff --git a/ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Person/RandomGenerator.java b/ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Person/RandomGenerator.java new file mode 100644 index 0000000..bab83cd --- /dev/null +++ b/ANU_STREAM_MAVEN_ASSIGNMENT_JBDL_58/src/com/Person/RandomGenerator.java @@ -0,0 +1,15 @@ +package Person; +import java.util.Random; +import java.util.List; +import java.util.stream.Collectors; + +public class RandomGenerator { + public void listOfInt(){ //random number generation + int min = 0; + int max = 1000; + int count = 20; + List randomIntegers = new Random().ints(count, min, max + 1).boxed().collect(Collectors.toList()); + randomIntegers.forEach(System.out::println); + + } +} From ba7fbf63c73fa1d32be53cd81004e5c97c76f846 Mon Sep 17 00:00:00 2001 From: Anugautam1998 Date: Sat, 30 Sep 2023 19:12:19 +0530 Subject: [PATCH 2/2] Anu |jbdl-58 Maven and Stream assignment --- .../nosql/mongodb/MongodbApplicationTests.java | 13 ------------- .../mysql/src/main/java/com/example/sql/Main.java | 2 -- 2 files changed, 15 deletions(-) delete mode 100644 ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/test/java/com/example/nosql/mongodb/MongodbApplicationTests.java diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/test/java/com/example/nosql/mongodb/MongodbApplicationTests.java b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/test/java/com/example/nosql/mongodb/MongodbApplicationTests.java deleted file mode 100644 index af9d6b7..0000000 --- a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mongodb/src/test/java/com/example/nosql/mongodb/MongodbApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.nosql.mongodb; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class MongodbApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/src/main/java/com/example/sql/Main.java b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/src/main/java/com/example/sql/Main.java index e588b6c..7c19f47 100644 --- a/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/src/main/java/com/example/sql/Main.java +++ b/ANU_MAVEN_JAR_DEPENDENCY_PROJECT_JDBL_58'/mysql/src/main/java/com/example/sql/Main.java @@ -1,9 +1,7 @@ package com.example.sql; -import org.springframework.boot.SpringApplication; public class Main { public static void main(String[] args) { - SpringApplication.run(Main.class, args); } }