Snippets Collections
interface Capture
{ int compute(int n); }

public class CaptureDemo
{   private int a = 100;
    
	public int getA(){ return this.a; }
	
	public static void main(String[] args)
	{
		CaptureDemo c1 = new CaptureDemo();
		System.out.println("Value: "+c1.getA());
		
		int x = 200;
		Capture ob = (n)-> {
			int z = 12;
			int result = z + n + x + c1.getA();
			c1.a = 9876;
			//x++;
			return result;
		};
		
		System.out.println(ob.compute(40));
		System.out.println("Value: "+c1.getA()); 
	}

}
import java.util.*; 
 
public class BinarySearchTree 
{ 
 class Node 
 {  int key; 
  Node left, right; 
   
  public Node(int data) 
  {  key = data; 
   left = right = null; 
  } 
 } 
   
 private Node root; 
  
 public BinarySearchTree() 
 { root=null; } 
 
 public void insert(int data) 
 {  root = insertRec(root, data); } 
  
 private Node insertRec(Node root,int key) 
 {  if (root == null)  
  { root = new Node(key); 
   return root; 
  }   
  if (key < root.key)   
   root.left = insertRec(root.left, key); 
  else if (key > root.key)  
   root.right = insertRec(root.right, key); 
 
  return root; 
 } 
  
 public void inorder() 
 { inorderRec(root); }  
  
 private void inorderRec(Node root) 
 { 
  if (root != null) { 
  inorderRec(root.left); 
  System.out.print(root.key + " "); 
  inorderRec(root.right); 
  } 
 } 
  
  
 
 
 
 
public void preorder() 
 {   preorderrec(root);  } 
  
 private void preorderrec(Node node) 
 { 
  if (node == null) 
   return; 
  System.out.print(node.key + " "); 
  preorderrec(node.left); 
  preorderrec(node.right); 
 } 
  
 public void postorder() 
 {   postorderrec(root); } 
  
 private void postorderrec(Node node) 
 { 
  if (node == null) 
   return; 
  postorderrec(node.left); 
  postorderrec(node.right); 
  System.out.print(node.key + " "); 
 } 
  
 public static void main(String[] args)  
 { 
  Scanner sc = new Scanner(System.in); 
  BinarySearchTree bst = new BinarySearchTree(); 
  String ch=""; 
  do{ 
  System.out.print("Enter the element to be inserted in the tree: "); 
   int n=sc.nextInt(); 
   sc.nextLine(); 
    
   bst.insert(n); 
 System.out.print("Do you want to insert another element? (Say 'yes'): "); 
   ch = sc.nextLine(); 
  }while(ch.equals("yes")); 
   
 System.out.print("Inorder Traversal : The elements in the tree are: "); 
  bst.inorder(); 
  System.out.println();  
 System.out.print("Preorder Traversal : The elements in the tree are: "); 
  bst.preorder(); 
  System.out.println();   
 System.out.print("Postorder Traversal : The elements in the tree are: "); 
  bst.postorder(); 
  System.out.println(); 
 } 
}

OUTPUT:

Enter the element to be inserted in the tree: 50
Do you want to insert another element? (Say 'yes'): yes
Enter the element to be inserted in the tree: 30
Do you want to insert another element? (Say 'yes'): yes
Enter the element to be inserted in the tree: 20
Do you want to insert another element? (Say 'yes'): yes
Enter the element to be inserted in the tree: 40
Do you want to insert another element? (Say 'yes'): yes
Enter the element to be inserted in the tree: 70
Do you want to insert another element? (Say 'yes'): yes
Enter the element to be inserted in the tree: 60
Do you want to insert another element? (Say 'yes'): yes
Enter the element to be inserted in the tree: 80
Do you want to insert another element? (Say 'yes'): no
Inorder Traversal : The elements in the tree are: 20 30 40 50 60 70 80 
Preorder Traversal : The elements in the tree are: 50 30 20 40 70 60 80 
Postorder Traversal : The elements in the tree are: 20 40 30 60 80 70 50
import java.util.*; 
 
public class BinarySearchTree3  
{ 
  class Node { 
    int key; 
    Node left, right; 
 
    public Node(int item) { 
      key = item; 
      left = right = null; 
    } 
  } 
 
  private Node root; 
 
  public BinarySearchTree3()  
  {  
    root = null; 
  } 
 
  public void insert(int key)  
  { root = insertKey(root, key); } 
 
  private Node insertKey(Node root, int key)  
  { if (root == null)  
    { 
      root = new Node(key); 
      return root; 
    } 
 
    if (key < root.key) 
      root.left = insertKey(root.left, key); 
    else if (key > root.key) 
      root.right = insertKey(root.right, key); 
 
    return root; 
  } 
 
  public void inorder() { 
    inorderRec(root); 
  } 
 
  private void inorderRec(Node root) { 
    if (root != null) { 
      inorderRec(root.left); 
      System.out.print(root.key + " "); 
      inorderRec(root.right); 
    } 
  } 
 
 
  public void deleteKey(int key)  
  { root = deleteRec(root, key); } 
 
  private Node deleteRec(Node root, int key)  
  { if (root == null) 
      return root; 
 
    if (key < root.key) 
      root.left = deleteRec(root.left, key); 
    else if (key > root.key) 
      root.right = deleteRec(root.right, key); 
    else  
 { if (root.left == null) 
        return root.right; 
      else if (root.right == null) 
        return root.left; 
    
      root.key = minValue(root.right); 
      root.right = deleteRec(root.right, root.key); 
    } 
    return root; 
  } 
   
  public int minValue(Node root) { 
    int minv = root.key; 
    while (root.left != null) { 
      minv = root.left.key; 
      root = root.left; 
    } 
    return minv; 
  } 
    
  public static void main(String[] args)  
  { 
  Scanner sc = new Scanner(System.in); 
  BinarySearchTree3 bst = new BinarySearchTree3(); 
  String ch=""; 
  do{ 
  System.out.print("Enter the element to be inserted in the tree: "); 
   int n=sc.nextInt(); 
   sc.nextLine(); 
    
   bst.insert(n); 
 System.out.print("Do you want to insert another element? (Say 'yes'): "); 
   ch = sc.nextLine(); 
  }while(ch.equals("yes")); 
  System.out.println(); 
 System.out.print("Inorder Traversal : The elements in the tree are: "); 
  bst.inorder(); 
  System.out.println(); 
System.out.print("Enter the element to be removed from the tree: "); 
int r=sc.nextInt(); 
sc.nextLine(); 
System.out.println(); 
bst.deleteKey(r); 
System.out.print("Inorder traversal after deletion of "); 
bst.inorder(); 
System.out.println(); 
} 
}




OUTPUT:

Enter the element to be inserted in the tree: 50
Do you want to insert another element? (Say 'yes'): yes
Enter the element to be inserted in the tree: 30
Do you want to insert another element? (Say 'yes'): yes
Enter the element to be inserted in the tree: 20
Do you want to insert another element? (Say 'yes'): yes
Enter the element to be inserted in the tree: 40
Do you want to insert another element? (Say 'yes'): yes
Enter the element to be inserted in the tree: 70
Do you want to insert another element? (Say 'yes'): yes
Enter the element to be inserted in the tree: 60
Do you want to insert another element? (Say 'yes'): yes
Enter the element to be inserted in the tree: 80
Do you want to insert another element? (Say 'yes'): no

Inorder Traversal : The elements in the tree are: 20 30 40 50 60 70 80 
Enter the element to be removed from the tree: 50

Inorder traversal after deletion of 50: 20 30 40 60 70 80 
interface StringFunction
{ String reverse(String s); }

public class BlockLambdaReverse
{
	public static void main(String[] args)
	{
		java.util.Scanner scan = new java.util.Scanner(System.in);
		
		StringFunction sf = (s) -> {
			String r = "";
			for(int i=s.length()-1; i>=0; i--)
				r += s.charAt(i);
			return r;
		};
		System.out.println("Enter an input string: ");
		String s = scan.nextLine();
		System.out.println("The reverse of "+s+" is "+sf.reverse(s));
	}
}
interface NumFunction
{ long factorial(int n); }

public class BlockLambdaDemo
{
	public static void main(String[] args)
	{
		NumFunction nf = (n) -> {
			            int result = 1;
						for(int i=2; i<=n; i++)
							result *= i;
						return result;
		};
		
		java.util.Scanner scan = new java.util.Scanner(System.in);
		
		System.out.println("Enter an integer: ");
		int n = scan.nextInt();
		System.out.println("The factorial of " + n + " is " + nf.factorial(n));
		
		System.out.println("Enter an integer: ");
		n = scan.nextInt();
		System.out.println("The factorial of " + n + " is " + nf.factorial(n));
		
	}
}
//Source.ccp

//Setup SDL
bool InitSDL() {
	//If failed to Initialize
	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
		cout << "Failed to Init SDL. Error: " << SDL_GetError() << "\n";
		return false;
	}

	//If Sucesss
	else {
		//Create Window
		gWindow = SDL_CreateWindow("MarioBrosClone", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN); 
		
		//Create renderer
		gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED);

		//Check if Window is null
		if (gWindow == NULL) {
			cout << "Failed to create Window, Error: " << SDL_GetError() << "\n";
			return false;
		}

		//Check if renderer is null;
		if (gRenderer == NULL) {
			cout << "Failed to create Renderer, Error " << SDL_GetError() << "\n";
			return false;
		}

		//Set Texture
		else {
			int imageFlags = IMG_INIT_PNG;

			if (!(IMG_Init(imageFlags)) && imageFlags) {
				cout << "Failed to load SDL_Image, Error " << SDL_GetError() << "\n";
				return false;
			}
		}

		//Create Mixer
		if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) {
			cout << "Mixer could not initialise. Error: " << Mix_GetError();
			return false;
		}

		if (TTF_Init() < 0) {
			cout << "Error: " << TTF_GetError() << endl;
			return false;
		}
	}

	return true;
}

//Close SDL
void CloseSDL() {
	SDL_DestroyWindow(gWindow);
	gWindow = NULL;

	IMG_Quit();
	SDL_Quit();

	SDL_DestroyRenderer(gRenderer);
	gRenderer = NULL;

	delete gTexture;
	gTexture = NULL;

	delete gameScreenManager;
	gameScreenManager = NULL;
}

//Render 
void Render() {
	//Clear Screen
	SDL_SetRenderDrawColor(gRenderer, 0x00, 0x00, 0x00, 0x00);
	SDL_RenderClear(gRenderer);
	
	//Render Texture to Screen
	gameScreenManager->Render();

	//Update Screen
	SDL_RenderPresent(gRenderer);
}
import java.util.*; 
 
public class ArrayListDemo 
{ 
 public static void main(String[] args) 
 { 
  ArrayList<String> al = new ArrayList<>(); 
   
  al.add("one"); al.add("two"); al.add("three"); al.add("four"); 
al.add("five"); 
  System.out.println("Contents: " + al); 
  System.out.println("Size: " + al.size()); 
  System.out.println(); 
   
  for(String s: al) 
   System.out.println(s); 
  System.out.println(); 
   
  for(int i=0; i<al.size(); i++) 
   System.out.println(al.get(i)); 
  System.out.println(); 
   
  Iterator it = al.iterator(); 
  ListIterator lit = al.listIterator(); 
  
  while(it.hasNext()) 
   System.out.println(it.next()); 
  System.out.println(); 
   
  while(lit.hasNext()) 
   System.out.println(lit.next()); 
  System.out.println(); 
   
  while(lit.hasPrevious()) 
   System.out.println(lit.previous()); 
  System.out.println(); 
     
  al.add(0, "zero"); 
  System.out.println("Contents: " + al); 
  System.out.println("Size: " + al.size()); 
   
  al.remove("one"); al.remove(0); 
  System.out.println("Contents: " + al); 
  System.out.println("Size: " + al.size()); 
   
 } 
} 
  
interface Args
{ String compute(String s); }

public class ArgsDemo
{
	public void m(Args obj, String s)
	{ System.out.println(obj.compute(s)); 
	 }
	
	public static void main(String[] args)
	{
		ArgsDemo ad = new ArgsDemo();
		
		Args L1 = (str) -> str.toUpperCase();
		ad.m(L1, args[0]);
		
		ad.m((str)->str.toLowerCase(), args[0]);
	}
}
interface Numbers
{ public abstract boolean checkFactor(int n, int m); }

public class LambdaFactor
{
	public static void main(String[] args)
	{
		java.util.Scanner scan = new java.util.Scanner(System.in);
		
		Numbers factor = (n, m) -> (n%m)==0;
		
		System.out.println("Enter two numbers: ");
		int n = scan.nextInt(); int m = scan.nextInt();
		System.out.println(m + " is a factor of " + n + ": " + factor.checkFactor(n, m));
	}
}
Buy 2000cc Pmma buttock injections
https://darkwebmarketbuyer.com/product/2000cc-pmma-buttock-injections/
Buy PMMA buttock injection
Our 2000cc PMMA buttock injections are the perfect solution for anyone looking to enhance their curves and achieve a more voluptuous figure. Made with high-quality PMMA microspheres, our injections provide long-lasting results that will leave you feeling confident and beautiful.

How It Works
PMMA buttock injections work by adding volume to the buttocks and hips, creating a more shapely figure. The PMMA microspheres are suspended in a sterile gel that is injected into the targeted area, allowing the microspheres to distribute evenly and create a natural-looking result. Over time, the body naturally metabolizes the gel, leaving behind the PMMA microspheres which continue to provide volume and shape.

Benefits
Long-lasting results
Natural-looking enhancement
Minimally invasive procedure
Safe and effective
Quick recovery time
Precautions
As with any medical procedure, there are some precautions that you should take before undergoing PMMA buttock injections. It’s important to discuss your medical history and any medications you are taking with your doctor, as some conditions and medications may interfere with the procedure. Additionally, you should avoid smoking and drinking alcohol before and after the procedure, as these activities can impair healing and increase the risk of complications. Pmma buttock injection for sale

https://darkwebmarketbuyer.com/product-category/pills/butt-breast-enlargement/

Side Effects
While PMMA buttock injections are generally safe, there are some side effects that you should be aware of, including swelling, bruising, and redness at the injection site. These side effects typically subside within a few days, but your doctor may recommend pain medication or other treatments to help manage any discomfort. It’s important to follow all post-procedure instructions provided by your doctor to minimize the risk of complications.

https://darkwebmarketbuyer.com/product/buy-1000cc-pmma-buttock-injections-online/

Buy 2000cc Pmma Buttock Injections Online
https://darkwebmarketbuyer.com/product/2000cc-pmma-buttock-injections/

Looking to buy 2000cc PMMA buttock injections online? Look no further than our authorized E-commerce website. We are committed to providing high-quality, safe, and effective beauty medicine products, and our PMMA buttock injections are no exception. Place your order today and start enjoying a more confident and beautiful you!
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDDy4LCTXRoGIGmuRex/9FkJLHxMd5KQFn0oTXhgc4wfW/YzU99U+JUSfbDpzqtMmzppKwtUSJ8fUPor7EqBA9FvRsWsm9JEAvj4REjiyNv0H22Msh8nFx71oKYSehOYpvm4WEBM9d7UL05kI0RbatK59ZtFrPR85qqFtLW6CkLBCFGNldbs+3hBN9gHsDrBXAVD8gurFgNmzyxd3Rh9tpncmliCVsUplQdAZqSo06mKIEIClWaVmps+v7tIkeqb+BM2SbmgD5pGm19gk8nFmk05DRob++nIL6VBBtH3Jd7gkzj9nggPbA8/Tjp+dxXK8uQEUylUoLyezVBKdVtsK9X2ytPIr/0797IOoS0AMVLlqaYO6wxxtGqS9M7EpvHsd2V9XPb3yciZftuul0YsGey14+OOPeupwD9cRdYjTEOUAl8wKD+8bnyOy1bb3Lb1FdfT/5JmsbHdLglKXzfaqoVXK+klNzzde7MV2jMDsh5iU1NZb1EMZzUjPTdOB63MEt2xC0ziBt8+JZd1N6aQ1wLUZ72UlTzSriID0mfq3Gt27VaUr58lFNmmljnKcBOy4LXfzDQxcSzRsm4Xo3SYt8vOeOag47ZOITD/JFQgurWFwk8V5nk6WXYGt4zCwZU7lXY5Crvx9u47FnFVk0N0U4A8Lz56+gkQUWsOkrnd03sbw==
library(dplyr, warn.conflicts = FALSE)
library(tidyr)
library(ggplot2)
library(NHSRdatasets)
library(janitor, warn.conflicts = FALSE) # to clean the titles and making them snake_case

ons_mortality <- NHSRdatasets::ons_mortality

deaths_data <- ons_mortality |>
  filter(date > "2020-01-01",
         category_2 %in% c("all ages", "Yorkshire and The Humber")) |>
  pivot_wider(
    id_cols = c(date, week_no),
    values_from = counts,
    names_from = category_2
  ) |>
  clean_names()

ggplot(data = deaths_data) +
  geom_line(aes(
    x = date, 
    y = all_ages,
    col = "all ages"
  )) +
  geom_line(aes(
    x = date, 
    y = yorkshire_and_the_humber,
    col = "Yorkshire and The Humber"
  )) +
  scale_y_continuous(
    name = "Yorkshire and The Humber",
    breaks = scales::pretty_breaks(10),
    sec.axis = sec_axis(~ . * 10,
                        name = "all ages",
                        breaks = scales::pretty_breaks(10)
    )
  ) +
  scale_colour_manual(
    name = NULL,
    values = c(
      "all ages" = "#CC2200",
      "Yorkshire and The Humber" = "black"
    )
  )
import java.util.*;
public class BinarySearchTree3 
{
 class Node {
 int key;
 Node left, right;
 public Node(int item) {
 key = item;
 left = right = null;
 }
 }
 private Node root;
 public BinarySearchTree3() 
 {
root = null;
 }
 public void insert(int key) 
 { root = insertKey(root, key); }
 private Node insertKey(Node root, int key) 
 { if (root == null) 
 {
 root = new Node(key);
 return root;
 }
 if (key < root.key)
 root.left = insertKey(root.left, key);
 else if (key > root.key)
 root.right = insertKey(root.right, key);
 return root;
 }
 public void inorder() {
 inorderRec(root);
 }
 private void inorderRec(Node root) {
 if (root != null) {
 inorderRec(root.left);
 System.out.print(root.key + " ");
 inorderRec(root.right);
 }
 }
 public void deleteKey(int key) 
 { root = deleteRec(root, key); }
 private Node deleteRec(Node root, int key) 
 { if (root == null)
 return root;
 if (key < root.key)
 root.left = deleteRec(root.left, key);
 else if (key > root.key)
 root.right = deleteRec(root.right, key);
 else 
{ if (root.left == null)
 return root.right;
 else if (root.right == null)
 return root.left;
 
 root.key = minValue(root.right);
 root.right = deleteRec(root.right, root.key);
 }
 return root;
 }
 
 public int minValue(Node root) {
 int minv = root.key;
 while (root.left != null) {
 minv = root.left.key;
 root = root.left;
 }
 return minv;
 }
 
 public static void main(String[] args) 
 {
Scanner sc = new Scanner(System.in);
BinarySearchTree3 bst = new BinarySearchTree3();
String ch="";
do{
System.out.print("Enter the element to be inserted in the tree: ");
int n=sc.nextInt();
sc.nextLine();
bst.insert(n);
System.out.print("Do you want to insert another element? (Say 'yes'): ");
ch = sc.nextLine();
}while(ch.equals("yes"));
System.out.println();
System.out.print("Inorder Traversal : The elements in the tree are: ");
bst.inorder();
System.out.println();
System.out.print("Enter the element to be removed from the tree: ");
int r=sc.nextInt();
sc.nextLine();
System.out.println();
bst.deleteKey(r);
System.out.print("Inorder traversal after deletion of "+r);
bst.inorder();
System.out.println();
 }
}
import java.util.*;
public class BinarySearchTree
{
class Node
{ int key;
Node left, right;
public Node(int data)
{ key = data;
left = right = null;
}
}
private Node root;
public BinarySearchTree()
{ root=null; }
public void insert(int data)
{ root = insertRec(root, data); }
private Node insertRec(Node root,int key)
{ if (root == null) 
{ root = new Node(key);
return root;
}
if (key < root.key) 
root.left = insertRec(root.left, key);
else if (key > root.key) 
root.right = insertRec(root.right, key);
return root;
}
public void inorder()
{ inorderRec(root); }
private void inorderRec(Node root)
{
if (root != null) {
inorderRec(root.left);
System.out.print(root.key + " ");
inorderRec(root.right);
}
}
public void preorder()
{ preorderrec(root); }
private void preorderrec(Node node)
{
if (node == null)
return;
System.out.print(node.key + " ");
preorderrec(node.left);
preorderrec(node.right);
}
public void postorder()
{ postorderrec(root); }
private void postorderrec(Node node)
{
if (node == null)
return;
postorderrec(node.left);
postorderrec(node.right);
System.out.print(node.key + " ");
}
public static void main(String[] args) 
{
Scanner sc = new Scanner(System.in);
BinarySearchTree bst = new BinarySearchTree();
String ch="";
do{
System.out.print("Enter the element to be inserted in the tree: ");
int n=sc.nextInt();
sc.nextLine();
bst.insert(n);
System.out.print("Do you want to insert another element? (Say 'yes'): ");
ch = sc.nextLine();
}while(ch.equals("yes"));
System.out.print("Inorder Traversal : The elements in the tree are: ");
bst.inorder();
System.out.println();
System.out.print("Preorder Traversal : The elements in the tree are: ");
bst.preorder();
System.out.println();
System.out.print("Postorder Traversal : The elements in the tree are: ");
bst.postorder();
System.out.println();
}
}
interface Refer
{ String m(String s); }

class StringOperation
{
	String reverse(String s)
	{   String res = "";
		for(int i=s.length()-1; i>=0; i--)
			res += s.charAt(i);
		return res;
	}
}

public class ReferDemo
{ 	
    static String compute(Refer r, String s)
	{ return r.m(s); }
	
    public static void main(String[] args)
	{   String s = "sample string";
		System.out.println(compute(new StringOperation()::reverse, s));
		/*
		Refer ob = (str)->{
			String res = "";
		for(int i=s.length()-1; i>=0; i--)
			res += s.charAt(i);
		return res;
		};
		
		System.out.println(compute(ob, s));
		*/
	}
}
interface Test
{ public abstract boolean check(int n);
}

public class LambdaTest
{
	public static void main(String[] args)
	{
		Test t = (n) -> (n%2)==0;  // Test t = (int n) -> (n%2)==0;
		                           // Test t = n -> (n%2)==0;
		
		java.util.Scanner scan = new java.util.Scanner(System.in);
		
		System.out.println("Enter a number: ");
		
		int x = scan.nextInt();
		System.out.println(x + " is even? " + t.check(x));
		
		x = scan.nextInt();
		System.out.println(x + " is even? " + t.check(x));
		
		t = (n) -> n >= 0;
		
		x = scan.nextInt();
		System.out.println(x + " is non-negative? " + t.check(x));
		
		x = scan.nextInt();
		System.out.println(x + " is non-negative? " + t.check(x));
	}
}
interface Capture
{ int compute(int n); }

public class CaptureDemo
{   private int a = 100;
    
	public int getA(){ return this.a; }
	
	public static void main(String[] args)
	{
		CaptureDemo c1 = new CaptureDemo();
		System.out.println("Value: "+c1.getA());
		
		int x = 200;
		Capture ob = (n)-> {
			int z = 12;
			int result = z + n + x + c1.getA();
			c1.a = 9876;
			//x++;
			return result;
		};
		
		System.out.println(ob.compute(40));
		System.out.println("Value: "+c1.getA()); 
	}

}
interface ExceptionDemo
{ String compute(String s) throws NullPointerException; }

class DemoOfLambdaException
{   public static void main(String[] args)
	{
		ExceptionDemo ed = (str) -> {
		if(str.length()==0 || str==null)
			throw new NullPointerException("No String is available");
		else
			return "The string "+str+" has "+str.length()+" characters.";
	};
	
	java.util.Scanner scan = new java.util.Scanner(System.in);
	System.out.println("Enter a String: ");
	String s = scan.nextLine();
	System.out.println(ed.compute(s));
	}
}
public interface MyNum
{ public abstract double getNum();
}
public class LambdaDemo
{
	public static void main(String[] args)
	{
		MyNum num = () -> 123.456;
		System.out.println("This is the value: " + num.getNum());
		
		num = () -> Math.random() * 100;
		System.out.println("This is the random value: " + num.getNum());
		System.out.println("This is one more random value: " + num.getNum());
	}
}
interface MyFunction<T>
{ T compute(T value); }

public class GenericLambda
{
	public static void main(String[] args)
	{
		MyFunction<String> reverse = (s) -> {
			String r = "";
			for(int i=s.length()-1; i>=0; i--)
				r += s.charAt(i);
			return r;
		};
		
		MyFunction<Integer> factorial = (n) -> {
			            int result = 1;
						for(int i=2; i<=n; i++)
							result *= i;
						return result;
		};
		
		System.out.println("Reversed string: " + reverse.compute("Lambda"));
		System.out.println("Factorial: " + factorial.compute(5));
	}
}
interface Numbers
{ public abstract boolean checkFactor(int n, int m); }

public class LambdaFactor
{
	public static void main(String[] args)
	{
		java.util.Scanner scan = new java.util.Scanner(System.in);
		
		Numbers factor = (n, m) -> (n%m)==0;
		
		System.out.println("Enter two numbers: ");
		int n = scan.nextInt(); int m = scan.nextInt();
		System.out.println(m + " is a factor of " + n + ": " + factor.checkFactor(n, m));
	}
}
interface Args
{ String compute(String s); }

public class ArgsDemo
{
	public void m(Args obj, String s)
	{ System.out.println(obj.compute(s)); 
	 }
	
	public static void main(String[] args)
	{
		ArgsDemo ad = new ArgsDemo();
		
		Args L1 = (str) -> str.toUpperCase();
		ad.m(L1, args[0]);
		
		ad.m((str)->str.toLowerCase(), args[0]);
	}
}
interface NumFunction
{ long factorial(int n); }

public class BlockLambdaDemo
{
	public static void main(String[] args)
	{
		NumFunction nf = (n) -> {
			            int result = 1;
						for(int i=2; i<=n; i++)
							result *= i;
						return result;
		};
		
		java.util.Scanner scan = new java.util.Scanner(System.in);
		
		System.out.println("Enter an integer: ");
		int n = scan.nextInt();
		System.out.println("The factorial of " + n + " is " + nf.factorial(n));
		
		System.out.println("Enter an integer: ");
		n = scan.nextInt();
		System.out.println("The factorial of " + n + " is " + nf.factorial(n));
		
	}
}
interface StringFunction
{ String reverse(String s); }

public class BlockLambdaReverse
{
	public static void main(String[] args)
	{
		java.util.Scanner scan = new java.util.Scanner(System.in);
		
		StringFunction sf = (s) -> {
			String r = "";
			for(int i=s.length()-1; i>=0; i--)
				r += s.charAt(i);
			return r;
		};
		System.out.println("Enter an input string: ");
		String s = scan.nextLine();
		System.out.println("The reverse of "+s+" is "+sf.reverse(s));
	}
}
import java.util.*;
public class TreeSetDemo
{ 
 class MyComparator implements Comparator<String>
{ public int compare(String s1, String s2)
{ if(s1.compareTo(s2)<0) 
return -1;
 if(s1.compareTo(s2)>0) 
 return +1;
 return 0;
}
}
public static void main(String[] args)
{
TreeSet<String> ts = 
 new TreeSet<>(new TreeSetDemo().new MyComparator());
ts.add("hello"); ts.add("world"); ts.add("version");
ts.add("main"); ts.add("method");
System.out.println("Contents: " + ts);
System.out.println();
System.out.println("Higher than \"main\": " + ts.higher("main"));
System.out.println("Lower than \"main\": " + ts.lower("main"));
System.out.println();
SortedSet s = ts.tailSet("method");
System.out.println("TailSet from \"method\": " + s);
s = ts.headSet("method");
System.out.println("HeadSet from \"method\": " + s);
System.out.println();
Iterator it = ts.iterator();
System.out.print("Iteration: ");
while(it.hasNext())
System.out.print(it.next()+" ");
System.out.println();
System.out.println();
Iterator it2 = ts.descendingIterator();
System.out.print("Iteration Descending: ");
while(it2.hasNext())
System.out.print(it2.next()+" ");
System.out.println();
System.out.println("First one: " + ts.pollFirst());
System.out.println("Last one: " + ts.pollLast());
System.out.println("Contents: " + ts);
}
}
import java.util.*;
public class LinkedHashSetDemo
{
public static void main(String[] args)
{
LinkedHashSet<String> hs = new LinkedHashSet<>();
hs.add("first"); hs.add("second"); hs.add("third"); 
hs.add("fourth"); hs.add("fifth"); hs.add("sixth");
System.out.println("Contents: " + hs);
System.out.println("Size: " + hs.size());
System.out.println();
Object[] arrayS = hs.toArray();
for(Object each: arrayS)
System.out.println(each);
System.out.println();
String[] arrayS2 = new String[hs.size()];
arrayS2 = hs.toArray(arrayS2);
for( String each: arrayS2)
System.out.println(each);
System.out.println();
Iterator it = hs.iterator();
while(it.hasNext())
System.out.println(it.next());
System.out.println();
System.out.println("Empty? " + hs.isEmpty());
System.out.println();
hs.remove("fourth");
System.out.println("Contents: " + hs);
System.out.println("Size: " + hs.size());
}
}
import java.util.*;
public class HashSetDemo
{
public static void main(String[] args)
{
HashSet<String> hs = new HashSet<>();
hs.add("first"); hs.add("second"); hs.add("third"); 
hs.add("fourth"); hs.add("fifth"); hs.add("sixth");
System.out.println("Contents: " + hs);
System.out.println("Size: " + hs.size());
System.out.println();
Object[] arrayS = hs.toArray();
for(Object each: arrayS)
System.out.println(each);
System.out.println();
String[] arrayS2 = new String[hs.size()];
arrayS2 = hs.toArray(arrayS2);
for( String each: arrayS2)
System.out.println(each);
System.out.println();
Iterator it = hs.iterator();
while(it.hasNext())
System.out.println(it.next());
System.out.println();
System.out.println("Empty? " + hs.isEmpty());
System.out.println();
hs.remove("fourth");
System.out.println("Contents: " + hs);
System.out.println("Size: " + hs.size());
}
}
import java.util.*;
public class TreeMapDemo
{
public static void main(String[] args)
{
TreeMap<String, Integer> tm = new TreeMap<>();
tm.put("Anand", 20);
tm.put("Mary", 20);
tm.put("Ravi", 21);
tm.put("John",19);
System.out.println("Contents: "+tm);
System.out.println();
Set<String> keys = tm.keySet();
for(String k: keys)
System.out.println(k+" -- "+tm.get(k));
System.out.println();
Set<Map.Entry<String, Integer>> entries = tm.entrySet();
for(Map.Entry<String,Integer> each: entries)
System.out.println(each.getKey()+" -- "+each.getValue());
System.out.println();
}
}
import boto3
from botocore.exceptions import ClientError
import logging

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

class ObjectWrapper:
    """Encapsulates S3 object actions."""

    def __init__(self, s3_object):
        """
        :param s3_object: A Boto3 Object resource. This is a high-level resource in Boto3
                          that wraps object actions in a class-like structure.
        """
        self.object = s3_object
        self.key = self.object.key

    def copy(self, dest_object):
        """
        Copies the object to another bucket.

        :param dest_object: The destination object initialized with a bucket and key.
                            This is a Boto3 Object resource.
        """
        try:
            dest_object.copy_from(
                CopySource={"Bucket": self.object.bucket_name, "Key": self.object.key}
            )
            dest_object.wait_until_exists()
            logger.info(
                "Copied object from %s:%s to %s:%s.",
                self.object.bucket_name,
                self.object.key,
                dest_object.bucket_name,
                dest_object.key,
            )
        except ClientError:
            logger.exception(
                "Couldn't copy object from %s/%s to %s/%s.",
                self.object.bucket_name,
                self.object.key,
                dest_object.bucket_name,
                dest_object.key,
            )
            raise

def copy_all_objects_between_buckets(source_bucket, dest_bucket):
    """
    Copies all objects from the source bucket to the destination bucket.

    :param source_bucket: The name of the source S3 bucket.
    :param dest_bucket: The name of the destination S3 bucket.
    """
    s3_resource = boto3.resource('s3')
    source_bucket_obj = s3_resource.Bucket(source_bucket)
    
    for s3_object in source_bucket_obj.objects.all():
        source_obj = s3_resource.Object(source_bucket, s3_object.key)
        dest_obj = s3_resource.Object(dest_bucket, s3_object.key)

        wrapper = ObjectWrapper(source_obj)
        wrapper.copy(dest_obj)

if __name__ == "__main__":
    # Example usage
    source_bucket_name = 'your-source-bucket'
    dest_bucket_name = 'your-destination-bucket'

    copy_all_objects_between_buckets(source_bucket_name, dest_bucket_name)
import java.util.*;
public class LinkedHashMapDemo
{
public static void main(String[] args)
{
LinkedHashMap<String, Integer> hm = new LinkedHashMap<>();
hm.put("Anand", 20);
hm.put("Mary", 20);
hm.put("Ravi", 21);
hm.put("John",19);
System.out.println("Contents: "+hm);
System.out.println();
Set<String> keys = hm.keySet();
for(String k: keys)
System.out.println(k+" -- "+hm.get(k));
System.out.println();
Set<Map.Entry<String, Integer>> entries = hm.entrySet();
for(Map.Entry<String,Integer> each: entries)
System.out.println(each.getKey()+" -- "+each.getValue());
System.out.println();
}
}
import java.util.*;
public class HashMapDemo
{
public static void main(String[] args)
{
HashMap<String, Integer> hm = new HashMap<>();
hm.put("Anand", 20);
hm.put("Mary", 20);
hm.put("Ravi", 21);
hm.put("John",19);
System.out.println("Contents: "+hm);
System.out.println();
Set<String> keys = hm.keySet();
for(String k: keys)
System.out.println(k+" -- "+hm.get(k));
System.out.println();
Set<Map.Entry<String, Integer>> entries = hm.entrySet();
for(Map.Entry<String,Integer> each: entries)
System.out.println(each.getKey()+" -- "+each.getValue());
System.out.println();
}
}
import java.util.*;
public class LinkedListDemo
{
public static void main(String[] args)
{
LinkedList<String> ll = new LinkedList<>();
ll.add("first"); ll.add("second"); ll.add("fourth");
System.out.println("Contents: " + ll);
System.out.println();
ll.add(2, "third"); ll.addFirst("zero");
System.out.println("Contents: " + ll);
System.out.println();
// experiment with more methods here and extend the program
}
}
import java.util.*;
public class ArrayListDemo
{
public static void main(String[] args)
{
ArrayList<String> al = new ArrayList<>();
al.add("one"); al.add("two"); al.add("three"); al.add("four"); 
al.add("five");
System.out.println("Contents: " + al);
System.out.println("Size: " + al.size());
System.out.println();
for(String s: al)
System.out.println(s);
System.out.println();
for(int i=0; i<al.size(); i++)
System.out.println(al.get(i));
System.out.println();
Iterator it = al.iterator();
ListIterator lit = al.listIterator();
while(it.hasNext())
System.out.println(it.next());
System.out.println();
while(lit.hasNext())
System.out.println(lit.next());
System.out.println();
while(lit.hasPrevious())
System.out.println(lit.previous());
System.out.println();
al.add(0, "zero");
System.out.println("Contents: " + al);
System.out.println("Size: " + al.size());
al.remove("one"); al.remove(0);
System.out.println("Contents: " + al);
System.out.println("Size: " + al.size())
}
}
import java.util.*;

public class SeparateChaining<T>
{	
	private static final int DEFAULT_TABLE_SIZE = 101;
	private List<T>[] theLists;
	private int currentSize;
	
	public SeparateChaining()
	{
		this(DEFAULT_TABLE_SIZE);
	}
	
	public SeparateChaining(int size)
	{
		theLists = new LinkedList[size];
		for(int i=0; i<theLists.length; i++)
			theLists[i] = new LinkedList<>();
	}
	
	public void insert(T element)
	{
		List<T> whichList = theLists[myhash(element)];
		if(!whichList.contains(element))
		{
			whichList.add(element);
			currentSize++;
		}
	}
	
	public void remove(T element)
	{
		List<T> whichList = theLists[myhash(element)];
		if(whichList.contains(element))
		{
			whichList.remove(element);
			currentSize--;
		}
	}
	
	public boolean contains(T element)
	{
		List<T> whichList = theLists[myhash(element)];
		return whichList.contains(element);
	}
	
	public void makeEmpty()
	{
		for( int i = 0; i < theLists.length; i++ )
			theLists[ i ].clear();
		currentSize = 0;
	}
	
	private int myhash(T element)
	{
		int hashValue = element.hashCode();
		hashValue %= theLists.length;
		if(hashValue < 0)
			hashValue += theLists.length;
		return hashValue;
	}
	
	public void showAll()
	{
		for(int i=0; i<theLists.length; i++)
			System.out.println("Chain "+i+" : "+theLists[i]);
	}
	
	public static void main(String[] args)
	{
		SeparateChaining<String> sc = new SeparateChaining(7);
		sc.insert("hello"); sc.insert("java"); sc.insert("world"); sc.insert("programming");
		sc.insert("separate"); sc.insert("chaining");
		System.out.println("java is present " + sc.contains("java"));
		sc.showAll();
		
	}
	
}
import java.util.*;

public class QuadraticProbing<T>
{   
	private static final int DEFAULT_TABLE_SIZE = 101;
	private HashEntry<T>[] array;
	private int currentSize;
	
	public QuadraticProbing()
	{	this(DEFAULT_TABLE_SIZE); }
	
	public QuadraticProbing(int size)
	{	array = new HashEntry[size]; 
		makeEmpty();
	}
	
	public void makeEmpty()
	{   currentSize = 0;
		for(int i=0; i<array.length; i++)
			array[i] = null;
	}
	
	public boolean contains(T element)
	{
		int currentPos = findPos(element);
		return isActive(currentPos);
	}
	
	private int findPos(T element)
	{
		int offset = 1;
		int currentPos = myhash(element);
		while(array[currentPos]!=null&&!array[currentPos].element.equals(element))
		{
			currentPos += offset;
			offset += 2;
			if(currentPos>=array.length)
				currentPos -= array.length;
		}
		return currentPos;
	}
	
	private boolean isActive(int currentPos)
	{
		return array[currentPos]!=null && array[currentPos].isActive;
	}
	
	public void insert(T element)
	{
		int currentPos = findPos(element);
		if(isActive(currentPos))
			return;
		array[currentPos] = new HashEntry<>(element, true);
	}
	
	public void remove(T element)
	{
		int currentPos = findPos(element);
		if(isActive(currentPos))
				array[currentPos].isActive = false;
	}
	
	private int myhash(T element)
	{   
		int hashValue = element.hashCode();
		hashValue %= array.length;
		if(hashValue < 0)
			hashValue += array.length;
		return hashValue;
	}
	
	private static class HashEntry<T>
	{
		public T element;
		public boolean isActive;
		
		public HashEntry(T e)
		{ this(e, true); }
		
		public HashEntry(T e, boolean i)
		{ element = e; isActive = i; }
		
		public T getElement(){ return this.element; }
	}
	
	public void showAll()
	{   for(HashEntry each: array)
			if(each != null)
				System.out.print(each.getElement()+"  ");
			else
				System.out.print("None ");
	}
	
	public static void main(String[] args)
	{
		QuadraticProbing<Integer> sc = new QuadraticProbing(10);
		sc.insert(89); sc.insert(18); sc.insert(49); sc.insert(58); sc.insert(69); 
		sc.showAll();
		
	}
}
 
# RECOMMENDED WAY
import boto3
client = boto3.client(
    s3,                         # boto3 will get the credentials either from
    region_name=us-east-1       # environment vars. or the .aws/credentials file.
)
class Superclass<T> {
    private T element;
    
    public Superclass(T element) {
        this.element = element;
    }
    
    public T getEle() {
        return this.element;
    }
}

class Subclass<T, V> extends Superclass<T> {
    private V value;
    
    public Subclass(T element, V value) {
        super(element);
        this.value = value;
    }
    
    public V getValue() {
        return this.value;
    }
}

public class Hierarchy {
    public static void main(String[] args) {
        System.out.println(" ABC");
        Subclass<String, Integer> h1 = new Subclass<>("abc", 123);
        System.out.println(h1.getEle());
        System.out.println(h1.getValue());
    }
}
star

Wed May 29 2024 16:24:14 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 16:23:46 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 16:22:55 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 16:20:50 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 16:20:10 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 16:19:35 GMT+0000 (Coordinated Universal Time)

@huyrtb123 #c++

star

Wed May 29 2024 16:19:32 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 16:17:48 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 16:15:58 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 16:10:32 GMT+0000 (Coordinated Universal Time) https://account.live.com/proofs/manage/additional?mkt

@shookthacr3ator

star

Wed May 29 2024 16:06:58 GMT+0000 (Coordinated Universal Time) https://darkwebmarketbuyer.com/product/2000cc-pmma-buttock-injections/

@darkwebmarket

star

Wed May 29 2024 16:05:25 GMT+0000 (Coordinated Universal Time) https://darkwebmarketbuyer.com/product/2000cc-pmma-buttock-injections/

@darkwebmarket

star

Wed May 29 2024 15:58:15 GMT+0000 (Coordinated Universal Time) https://s1477.usc1.mysecurecloudhost.com:2083/cpsess1902818660/frontend/jupiter/telnet/keys/editkey.html?key

@shookthacr3ator

star

Wed May 29 2024 15:39:23 GMT+0000 (Coordinated Universal Time) https://extensions.dev/

@shookthacr3ator

star

Wed May 29 2024 15:25:57 GMT+0000 (Coordinated Universal Time) https://nhsrcommunity.com/code-snippets-2-scale-y-axes-in-ggplot2/

@andrewbruce #r

star

Wed May 29 2024 14:19:37 GMT+0000 (Coordinated Universal Time) https://www.creativefabrica.com/studio/

@shookthacr3ator

star

Wed May 29 2024 14:18:02 GMT+0000 (Coordinated Universal Time) https://www.creativefabrica.com/freebies/

@shookthacr3ator

star

Wed May 29 2024 14:16:39 GMT+0000 (Coordinated Universal Time) https://www.creativefabrica.com/freebies/

@shookthacr3ator

star

Wed May 29 2024 14:08:33 GMT+0000 (Coordinated Universal Time) https://www.vecteezy.com/reverse-image-search

@shookthacr3ator

star

Wed May 29 2024 14:08:00 GMT+0000 (Coordinated Universal Time) https://www.vecteezy.com/developers

@shookthacr3ator

star

Wed May 29 2024 14:04:50 GMT+0000 (Coordinated Universal Time) https://www.freepik.com/developers/dashboard/api-key

@shookthacr3ator

star

Wed May 29 2024 14:04:28 GMT+0000 (Coordinated Universal Time) https://docs.freepik.com/api-reference/introduction

@shookthacr3ator

star

Wed May 29 2024 14:03:31 GMT+0000 (Coordinated Universal Time) https://www.freepik.com/api?_gl

@shookthacr3ator

star

Wed May 29 2024 13:38:32 GMT+0000 (Coordinated Universal Time) https://icons8.com/icons

@shookthacr3ator

star

Wed May 29 2024 13:38:00 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:37:05 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:23:48 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:23:01 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:22:23 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:21:43 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:20:55 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:20:03 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:19:24 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:18:36 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:17:51 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:17:10 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:16:23 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:15:02 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:14:12 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:13:09 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:10:51 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:10:04 GMT+0000 (Coordinated Universal Time)

@krishna01 ##copy_files_from_s3 ##copy_bucket

star

Wed May 29 2024 13:09:34 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:08:42 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:07:18 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:05:38 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:01:31 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 13:00:43 GMT+0000 (Coordinated Universal Time)

@signup

star

Wed May 29 2024 12:18:34 GMT+0000 (Coordinated Universal Time) https://www.prplbx.com/resources/blog/aws-sdk-python-boto3-cheat-sheet/

@krishna01

star

Wed May 29 2024 10:18:09 GMT+0000 (Coordinated Universal Time)

@signup

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension