This file contains hidden or 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.Arrays; | |
| import java.util.HashMap; | |
| import java.util.List; | |
| import java.util.Map; | |
| import java.util.function.BiConsumer; | |
| import java.util.function.Consumer; | |
| public class ForEachDemo { | |
| public static void main(String[] args) { |
This file contains hidden or 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.Arrays; | |
| import java.util.List; | |
| public class StreamOperations { | |
| public static void main(String[] args) { | |
| List<Integer> numbers = Arrays.asList(-1, 3, 5, 7, 9, 2, 4, 6, 8); | |
| List<String> names = Arrays.asList("Java", "PHP", "JavaScript", "Python"); |
This file contains hidden or 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.concurrent.*; | |
| class Task implements Runnable { | |
| private String name; | |
| Task(String name){ | |
| this.name = name; | |
| } |
This file contains hidden or 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
| // RESOURCE GOING TO BE SHARED | |
| class Resource { | |
| private String name; | |
| public synchronized void getAccess(String resource) { | |
| System.out.println(resource+" is accessed by "+Thread.currentThread().getName()); | |
| try { | |
| Thread.sleep(1000); | |
| } | |
| catch (Exception e) { | |
| System.out.println("Thread Exception Found!"); |
This file contains hidden or 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
| package com.nCinga.threads; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import java.util.Random; | |
| import java.util.concurrent.*; | |
| class Square implements Callable<Integer> { | |
| private Integer number; |
This file contains hidden or 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 ThreadOne extends Thread { | |
| public void run(){ | |
| for (int i = 0; i < 10; i++) { | |
| System.out.println(Thread.currentThread().getName()+" => "+i); | |
| } | |
| } | |
| } | |
| class ThreadTwo implements Runnable { | |
| public void run(){ |
This file contains hidden or 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
| <?php | |
| namespace App\Providers; | |
| use Illuminate\Support\Facades\Schema; | |
| use Illuminate\Support\ServiceProvider; | |
| class AppServiceProvider extends ServiceProvider | |
| { | |
| /** | |
| * Register any application services. |
This file contains hidden or 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 SingletonDemo { | |
| private static SingletonDemo instance; | |
| private SingletonDemo(){} | |
| public static SingletonDemo getInstance(){ | |
| if(instance == null){ | |
| instance = new SingletonDemo(); | |
| } |
This file contains hidden or 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; | |
| public class DBConnection { | |
| private Connection con; | |
| private static DBConnection dbCon; | |
| private DBConnection() throws ClassNotFoundException, SQLException { |
This file contains hidden or 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
| ArrayList<Integer> list = new ArrayList<>(); | |
| list.add(1); | |
| list.add(2); | |
| list.add(1); | |
| list.add(3); | |
| list.add(4); | |
| Map<Integer, Integer> map = new HashMap<>(); | |
| for(Integer i: list){ | |
| int count = 0; | |
| for(Integer j: list){ |