This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Came across this cool code with neat code style for BFS | |
import java.util.ArrayList; | |
import java.util.LinkedList; | |
import java.util.List; | |
class Node { | |
String data; | |
boolean visited; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.Stack; | |
class Node { | |
String data; | |
boolean visited; | |
List<Node> neighbours = new ArrayList<Node>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.ref.PhantomReference; | |
import java.lang.ref.ReferenceQueue; | |
import java.lang.ref.SoftReference; | |
import java.lang.ref.WeakReference; | |
class SomeClass{ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void someMethod(){ | |
/** Create a Emp List and add dummy values to Sort **/ | |
List<Employee> myEmpList = new ArrayList<Employee>(); | |
Employee emp = new Employee(); | |
emp.salary = 5000; | |
emp.name = "Arnold"; | |
myEmpList.add(emp); | |
emp = new Employee(); | |
emp.salary = 15000; | |
emp.name = "Clooney"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node { | |
int data; | |
Node next; | |
public Node(int data) { | |
this.data = data; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Item { | |
int data; | |
Item next; | |
public Item(int data) { | |
this.data = data; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Item { | |
intdata; | |
Item next; | |
public Item(int data) { | |
this.data = data; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.sql.Connection; | |
import java.sql.DriverManager; | |
import java.sql.SQLException; | |
import java.util.ArrayList; | |
import java.util.List; | |
/** A Connection Pool with 5 Available Connections **/ | |
class ConnectionPool { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** The Resource Class - The root cause of all fight **/ | |
class Resource { | |
private Boolean isProduced = false; | |
private String data = "EMPTY"; | |
/** Put method : puts only if is not already produced **/ | |
public synchronized void put(String data) throws InterruptedException { | |
if (isProduced) { | |
wait(); // Not Consumed Yet,Wait for consumer's signal. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Item{ | |
Integer data; | |
Item next; | |
public Item(){} | |
public Item(Integer data){ |
OlderNewer