Skip to content

Instantly share code, notes, and snippets.

-- junit-jupiter-engine alone is good enough to write test cases in Junit 5..
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.1</version>
<scope>test</scope>
</dependency>
-- The above one will add transitive dependencies as below..
Among these dependencies, there is 'junit-jupiter-api' which contains the classes and interfaces that is required to compile your test cases..
(1) // Java program to illustrate join() method in Java
import java.lang.*;
public class JoinDemo implements Runnable {
public void run() {
System.out.println("INSIDE Thread t run() .. Thread t starting.........................................................");
try {
System.out.println("Before sleep");
@codinko
codinko / FindEmployeesWithSameSalary.java8
Last active December 11, 2021 07:04
FindEmployeesWithSameSalary Java 8 Streams
package com.learn.java;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public class FindEmployeesWithSameSalary {
package com.learn.java;
import java.util.ArrayList;
import java.util.List;
public class TryFinally {
public static void main(String[] args) {
List a = null;
package com.learn.java;
public class Main {
public static void main(String[] args) {
//case-1: serializing a custom class that does not implement serializable interface
////OUTPUT - Got exception while doing serialization... : java.io.NotSerializableException: com.learn.java.Student
//case-2: serializing a custom class that implement serializable interface, but no serialversionUID. Deserialize it . ( if JVM same then it will be success..
class Singleton {
private static Singleton instance = null;
public String s;
private Singleton()
{
s = "hey i am ston";
}
public static Singleton getInstance()
@codinko
codinko / gist:42fa0c71b3eb039ad08b79accc631f6c
Last active October 13, 2021 16:57
immutable-deepcopy
// Java Program to Create An Immutable Class
import java.util.HashMap;
import java.util.Map;
final class Student {
private final String name;
private final int rollNo;
private final Map<String, String> map1;
@codinko
codinko / tomcat-server-database-connection-pool-settings2.xml
Created May 2, 2021 15:36
tomcat-server-database-connection-pool-settings2
<property name="logAbandoned" value="true"/>
<property name="removeAbandoned" value="true"/>
<property name="removeAbandonedTimeout" value="30"/>
<property name="timeBetweenEvictionRunsMillis" value="30000" />
@codinko
codinko / tomcat-server-db-conn-pool.xml
Last active May 2, 2021 14:00
tomcat Server-database-connection-pool-configs.xml
<bean id="XXX" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
2
<property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
3
<property name="url" value="${oracle.url}"/>
4
<property name="username" value="${oracle.user}"/>
5
<property name="password" value="${oracle.password}"/>
6
@codinko
codinko / LRUCache-output.java
Created May 1, 2021 13:32
LRU Cache Java implementation Using Custom created Double linked List and Hashmap - OUTPUT
jdk1.8.0_231
{1=key = 1 | value = mango | leftValue = mango | rightValue = null}
******************************************************
{1=key = 1 | value = mango | leftValue = apple | rightValue = null,
2=key = 2 | value = apple | leftValue = null | rightValue = mango}
******************************************************
{1=key = 1 | value = mango | leftValue = apple | rightValue = null,
2=key = 2 | value = apple | leftValue = orange | rightValue = mango,
3=key = 3 | value = orange | leftValue = null | rightValue = apple}