Skip to content

Commit

Permalink
upload Java8
Browse files Browse the repository at this point in the history
  • Loading branch information
ohbus committed Aug 30, 2020
1 parent 1ca24db commit 8596e37
Show file tree
Hide file tree
Showing 30 changed files with 786 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,17 @@ jobs:
java-version: 1.8
- name: Build with Maven
run: mvn -B clean verify --file Servlets_JSP/pom.xml


build-tm12:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn -B clean verify --file Java8/pom.xml
38 changes: 38 additions & 0 deletions Java8/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.subho.wipro</groupId>
<artifactId>pjp.tm12</artifactId>
<version>1.0</version>

<packaging>jar</packaging>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Subhrodip Apache Maven Packages</name>
<url>https://maven.pkg.github.com/ohbus/PJP</url>
</repository>
</distributionManagement>

<name>pjp.tm12</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>

</dependencies>
</project>
13 changes: 13 additions & 0 deletions Java8/src/main/java/com/subho/wipro/pjp/tm12/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.subho.wipro.pjp.tm12;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.subho.wipro.pjp.tm12.DateTimeAPI;

//Write a program to display today's date and the date after ten days.

import java.time.LocalDate;

public class Assigment01 {

public static void main(String[] args) {
// TODO Auto-generated method stub
LocalDate date = LocalDate.now();
System.out.println("Todays Date : " + date);
System.out.println("Date after 10 days : " + date.plusDays(10));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.subho.wipro.pjp.tm12.DateTimeAPI;

// Write a program to find the date of next month second Sunday.

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;

public class Assigment02 {

public static void main(String[] args) {
// TODO Auto-generated method stub
LocalDate secondSunday = LocalDate.now().plusMonths(1).with(TemporalAdjusters.dayOfWeekInMonth(2, DayOfWeek.SUNDAY));
System.out.println(secondSunday);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.subho.wipro.pjp.tm12.DateTimeAPI;

//Write a program to calculate your experience (no of years, no of months & no of days) in Wipro.

import java.time.LocalDate;
import java.time.Period;

public class Assigment03 {

public static void main(String[] args) {
// TODO Auto-generated method stub
LocalDate joiningDate = LocalDate.of(2015,5,5);
Period d = Period.between(joiningDate,LocalDate.now());
int days = d.getDays();
int months = d.getMonths();
int years = d.getYears();
System.out.println("Experience : " + years + " years " + months + " months " + days + " days." );
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.subho.wipro.pjp.tm12.DateTimeAPI;

//Write a program to check whether the current year is a leap year.

import java.time.LocalDate;

public class Assigment04 {

public static void main(String[] args) {
// TODO Auto-generated method stub
LocalDate date = LocalDate.now();
if(date.isLeapYear())
System.out.println("Current Year is a leap year");
else
System.out.println("Current Year is not a leap year");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.subho.wipro.pjp.tm12.DateTimeAPI;

// Write a program to display the current time and the time after 25 minutes.

import java.time.LocalTime;

public class Assigment05 {

public static void main(String[] args) {
// TODO Auto-generated method stub
LocalTime time = LocalTime.now();
System.out.println("Time : " + time );
System.out.println("Time after 25 minutes : " + time.plusMinutes(25));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.subho.wipro.pjp.tm12.DateTimeAPI;

//Write a program to display the current time and the time before 5 hours and 30 minutes.

import java.time.LocalTime;

public class Assigment06 {

public static void main(String[] args) {
// TODO Auto-generated method stub
LocalTime time = LocalTime.now();
System.out.println("Time : " + time );
System.out.println("Time before 5 hours 30 minutes : " + time.minusMinutes(30).minusHours(5) );
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*Write a program to create an ArrayList and add the weekdays.
Iterate and print all the elements using forEach method
*/

package com.subho.wipro.pjp.tm12.ForEach;

import java.util.ArrayList;
import java.util.Arrays;

public class Assignment01 {

public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<String> arrL = new ArrayList<String>(
Arrays.asList("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"));

arrL.forEach(day -> System.out.println(day));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* Create an ArrayList and add 5 Employee(id,name,address,salary) objects.
Retrieve the objects from the ArrayList using forEach and print the Employee details.
*/

package com.subho.wipro.pjp.tm12.ForEach;

import java.util.ArrayList;

class Employee {
int id;
double salary;
String address, name;

Employee(int id, double salary, String name, String address) {
this.id = id;
this.salary = salary;
this.name = name;
this.address = address;
}
}

public class Assignment02 {

public static void main(String[] args) {
// TODO Auto-generated method stub
Employee emp1 = new Employee(1, 100.0, "James", "Kolkata");
Employee emp2 = new Employee(2, 200.0, "Kames", "Colkata");
Employee emp3 = new Employee(3, 300.0, "Lames", "Lolkata");
Employee emp4 = new Employee(4, 400.0, "Names", "Tolkata");
Employee emp5 = new Employee(5, 500.0, "Pames", "Bolkata");

ArrayList<Employee> empList = new ArrayList<Employee>();
empList.add(emp1);
empList.add(emp2);
empList.add(emp3);
empList.add(emp4);
empList.add(emp5);

empList.forEach(emp -> System.out.println(
"ID : " + emp.id + " Name : " + emp.name + " Salary : " + emp.salary + " Address : " + emp.address));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.subho.wipro.pjp.tm12.Interfaces;

/*Create an interface Vehicle with a default method message() that returns nothing and prints "Inside Vehicle".
Create an interface FourWheeler with a default method message() that returns nothing and prints "Inside FourWheeler".
Create a class Car implementing these two interfaces.
In this class, Override the message() method and call the message() method of the Vehicle interface using super keyword.
Instantiate the class, call the message method and observe the output.
*/

interface Vehicle {
default void message() {
System.out.println("Inside Vehicle");
}
}

interface FourWheeler {
default void message() {
System.out.println("Inside FourWheeler");
}
}

class Car implements Vehicle, FourWheeler {

@Override
public void message() {
// TODO Auto-generated method stub
Vehicle.super.message();
}

}

public class Assignment01 {

public static void main(String[] args) {
// TODO Auto-generated method stub
Car car = new Car();
car.message();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.subho.wipro.pjp.tm12.Interfaces;

/*Create an interface Test with an abstract method "int myFunction".
This function takes three integer parameters.
Write a program to create two Test reference variables t1 and t2.
t1 should add three integer parameters and t2 should multiply three integer parameters, using lambda expression.
Call myFunction using t1 and t2 reference variables, by passing three integer values and print the result.
*/

interface Test {
int myFunction(int x, int y, int z);
}

public class Assignment02 {

public static void main(String[] args) {
// TODO Auto-generated method stub
Test t1 = (x, y, z) -> (x + y + z);
Test t2 = (x, y, z) -> (x * y * z);

System.out.println(t1.myFunction(10, 20, 30));
System.out.println(t2.myFunction(10, 20, 30));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.subho.wipro.pjp.tm12.LambdaExpressions;

/*Create an ArrayList al and add 25 random numbers.
Write a code to print all the prime numbers that are present in it, using lambda expression.
*/

import java.util.ArrayList;
import java.util.Random;

public class Assignment01 {

public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<Integer> al = new ArrayList<Integer>();
Random random = new Random();
for(int i = 0; i < 25; i++){
al.add(random.nextInt(100));
}
System.out.println("Array : " +al.toString());
System.out.print("Prime Nos : ");
al.forEach(num -> {
boolean isPrime = true;
for (int i = 2; i <= (int) Math.sqrt(num); i++) {
if (num % i == 0) {
isPrime = false;
break;
}
}
System.out.print(isPrime ? num + " " : "");
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.subho.wipro.pjp.tm12.LambdaExpressions;

/*Create an ArrayList al and add 10 different words.
Write a code to print all the Strings in reverse order, using lambda expression.
*/

import java.util.ArrayList;

public class Assignment02 {

public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<StringBuffer> al = new ArrayList<StringBuffer>();
String[] wordsArray = { "Java", "Python", "C++", "C", "JavaScript", "Go", "Rust", "Bash", "Haskell", "Ruby" };

for (String word : wordsArray) {
StringBuffer sb = new StringBuffer(word);
al.add(sb);
}
al.forEach(word -> System.out.print(word.reverse() + " "));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.subho.wipro.pjp.tm12.LambdaExpressions;

/*Create an ArrayList al and add 10 different words.
Write a code to print all the Strings whose length is odd, using lambda expression.
*/

import java.util.ArrayList;
import java.util.Arrays;

public class Assignment03 {

public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<String> al = new ArrayList<String>(
Arrays.asList("Java", "Python", "C++", "C", "JavaScript", "Go", "Rust", "Bash", "Haskell", "Ruby"));

al.forEach(word -> System.out.print((word.length() % 2 != 0) ? word + " " : ""));
}

}
Loading

0 comments on commit 8596e37

Please sign in to comment.