code-rag-bench/online-tutorials huggingface dataset:
Stack push() Method in Java

10 Jun, 2022
Java.util.Stack.push(E element) method is used to push an element into the Stack. The element gets pushed onto the top of the Stack.
Syntax:
STACK.push(E element)
Parameters: The method accepts one parameter element of type Stack and refers to the element to be pushed into the stack.
Return Value: The method returns the argument passed.  It also accepts the null value unlike ArrayDeque.push() which throws java.lang.NullPointerException on doing the same.
Below programs illustrate the Java.util.Stack.push() method: 
Program 1: Adding String elements into the Stack. 
Java
// Java Code to illustrate push() Method import java.util.*; // Main classpublic class StackDemo {     // Main driver method    public static void main(String args[])    {        // Creating an empty Stack        Stack& lt;        String& gt;        STACK = new Stack& lt;        String& gt;        ();         // Adding elements into the stack        // using push() method        STACK.push(" Welcome & quot;);        STACK.push(" To & quot;);        STACK.push(" Geeks & quot;);        STACK.push(" For & quot;);        STACK.push(" Geeks & quot;);         // Displaying the Stack        System.out.println(" Initial Stack                           : "                           + STACK);         // Pushing elements into the stack        STACK.push(" Hello & quot;);        STACK.push(" World & quot;);         // Displaying the final Stack        System.out.println(" Final Stack                           : "                           + STACK);    }}
Initial Stack: [Welcome, To, Geeks, For, Geeks]
Final Stack: [Welcome, To, Geeks, For, Geeks, Hello, World]
Program 2: Adding Integer elements into the Stack. 
Java
// Java code to illustrate push() methodimport java.util.*; public class StackDemo {    public static void main(String args[])    {        // Creating an empty Stack        Stack<Integer> STACK = new Stack<Integer>();         // Use push() to add elements into the Stack        STACK.push(10);        STACK.push(15);        STACK.push(30);        STACK.push(20);        STACK.push(5);        STACK.push(null);         // Displaying the Stack        System.out.println("Initial Stack: " + STACK);         // Pushing elements into the Stack        STACK.push(1254);        STACK.push(4521);         // Displaying the final Stack        System.out.println("Final Stack: " + STACK);    }}
Initial Stack: [10, 15, 30, 20, 5]
Final Stack: [10, 15, 30, 20, 5, 1254, 4521]
anand00525
Java - util package
Java-Collections
Java-Functions
Java-Stack
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Java
Arrays.sort() in Java with examples
Reverse a string in Java
Split() String method in Java with examples
Object Oriented Programming (OOPs) Concept in Java
For-each loop in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
ArrayList in Java
jQuery UI Dialog position Option

22 Mar, 2021
jQuery UI consists of GUI widgets, visual effects, and themes implemented using HTML, CSS, and jQuery. jQuery UI is great for building UI interfaces for the webpages. The jQuery UI Dialog position Option is used to set the position of dialog box.
Syntax:
$( ".selector" ).dialog({
  position: { 
    my: "left top", 
    at: "left bottom", 
    of: button 
  }
});
CDN Link: First, add jQuery UI scripts needed for your project.
<link rel=”stylesheet” href=”https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css”><script src=”https://code.jquery.com/jquery-1.10.2.js”></script><script src=”https://code.jquery.com/ui/1.10.4/jquery-ui.js”></script>
Example:
HTML
<!doctype html><html lang="en">  <head>    <meta charset="utf-8">    <link href=    "https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css"        rel="stylesheet">    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>    <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>      <script>        $(function () {            $("#gfg").dialog({                autoOpen: false,                position: {                    at: "center"                }            });            $("#geeks").click(function () {                $("#gfg").dialog("open");            });        });    </script></head>  <body style="text-align: center;">    <h1 style="color:green;">GeeksforGeeks</h1>    <h3>jQuery UI Dialog position Option</h3>      <button id="geeks">Open Dialog</button>      <div id="gfg" title="GeeksforGeeks">        Welcome to GeeksforGeeks    </div></body>  </html>
Output:
Reference: https://api.jqueryui.com/dialog/#option-position
HTML-Tags
jQuery-Methods
jQuery-UI
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to get the value in an input text box using jQuery ?
How to prevent Body from scrolling when a modal is opened using jQuery ?
jQuery | ajax() Method
jQuery | removeAttr() with Examples
jQuery | parent() & parents() with Examples
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
How to Calculate Weighted Average in Excel?

15 May, 2021
Have you ever think why we need an average or weightage average? In our daily, we can’t calculate everything, let’s suppose I am asking how’s the weather for a week, you are not going to tell me every day’s temperature, but an estimation here comes to the concept of an Average. Mathematically you can evaluate the average=  Sum of Values/Number of Values, and the values carry equal weightage.
Now let’s take another example you are in university, and you got your result of the semester exam. Since the semester consists of minor and major where minor carries 25% weightage and major carries 75% of weightage, now how will you calculate your average? So here comes a concept of weightage average where we consider the weight of every value.
In order to calculate the weighted average, we will use two functions in Excel, the first one is the sum function, and the other SUMPRODUCT function, let’s discuss it one by one.
It is an inbuilt function in Excel, helps to sum the numerical data in a range of cells. The function enables us to calculate multiple data very easily.
= SUM (number1, [number2],... )
For example, you are purchasing class 12  science textbooks for donating to the NGO, so now you have to calculate the total number of books, so here you simply use the sum function.
It is an inbuilt function in Excel, it will return the sum of products of the value given in the argument or an array. This function usually uses when you need to multiply many cells together.
= SUMPRODUCT ( array1, [array2],[array3],...)
For example, you are purchasing class 12 textbooks for donating to the NGO, so now you have to calculate the total price.  So here’s this function comes handy, you will first enter array 1 and the put comma and again array 2 and then press enter, you will get your result, which is 5780.
Now we are clear with the concept of both SUM function and SUMPRODUCT function now let’s calculate the weightage average. So in Excel to calculate weightage average is SUMPRODUCT/ SUM.
Weightage Average = SUMPRODUCT ( array1, [array2],[array3],...)/SUM (number1, [number2],...) 
 Let’s understand with an example, you have to calculate your college marks, but every subject has a different average. So we can use the weightage average to calculate our average marks.  So Now put the values in the formula which is:
 weightage average = SUMPRODUCT(B1:B6, C2: C6)/SUM(C2:C6)
 And then hit enter, you will get your result 82.25.
Example of weightage average
Picked
Excel
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Delete Blank Columns in Excel?
How to Normalize Data in Excel?
How to Get Length of Array in Excel VBA?
How to Find the Last Used Row and Column in Excel VBA?
How to Use Solver in Excel?
How to make a 3 Axis Graph using Excel?
Introduction to Excel Spreadsheet
Macros in Excel
How to Create a Macro in Excel?
How to Show Percentages in Stacked Column Chart in Excel?
How to show webcam in TkInter Window?

Python libraries are independent and thus they all can be used for different purposes
while building a particular featured application. In this example, we will build an application
using OpenCV and Tkinter library. OpenCV is a Python library that is used to work with
Computer Vision and other artificial artifacts. Using the OpenCV module, we have to show
the webcam in a tkinter window.
To create the application, you are required to install open-cv in your local machine and make sure that Python Pillow package is pre-installed. You can install these packages by typing the following commands,
pip install open-cv
pip install Pillow
Once the installation has been done, we can start creating the structure and GUI of the application. The basic functionality of our application would be to open the web camera (if possible) using OpenCV. So, to display each and every captured frame, we can use Python Pillow (PIL) package which converts the frame into an Image. The Image now can be used in a Label widget that iteratively displays every captured frame in the window.
# Import required Libraries
from tkinter import *
from PIL import Image, ImageTk
import cv2

# Create an instance of TKinter Window or frame
win = Tk()

# Set the size of the window
win.geometry("700x350")

# Create a Label to capture the Video frames
label =Label(win)
label.grid(row=0, column=0)
cap= cv2.VideoCapture(0)

# Define function to show frame
def show_frames():
   # Get the latest frame and convert into Image
   cv2image= cv2.cvtColor(cap.read()[1],cv2.COLOR_BGR2RGB)
   img = Image.fromarray(cv2image)
   # Convert image to PhotoImage
   imgtk = ImageTk.PhotoImage(image = img)
   label.imgtk = imgtk
   label.configure(image=imgtk)
   # Repeat after an interval to capture continiously
   label.after(20, show_frames)

show_frames()
win.mainloop()
Whenever we run the above code, it will turn on the webcam and the output will display in the tkinter window.
Inheritance and Friendship in C++

17 Dec, 2021
Inheritance in C++: This is an OOPS concept. It allows creating classes that are derived from other classes so that they automatically include some of the functionality of its base class and some functionality of its own. (See this article for reference)
Friendship in C++: Usually, private and protected members of a class cannot be accessed from outside the same class in which they are declared. However, a friend class has the access to the protected and private members of the first one. Classes that are ‘friends’ can access not just the public members, but the private and protected members too. (See this article for reference)
Difference between Inheritance and Friendship in C++: In C++, friendship is not inherited. If a base class has a friend function, then the function doesn’t become a friend of the derived class(es). 
For example, the following program prints an error because the show() which is a friend of base class A tries to access private data of derived class B. 
C++
// CPP Program to demonstrate the relation between// Inheritance and Friendship#include <iostream>using namespace std;  // Parent Classclass A {protected:    int x;  public:    A() { x = 0; }    friend void show();};  // Child Classclass B : public A {private:    int y;  public:    B() { y = 0; }};  void show(){    B b;    cout << "The default value of A::x = " << b.x;      // Can't access private member declared in class 'B'    cout << "The default value of B::y = " << b.y;}  int main(){    show();    getchar();    return 0;}
Output
prog.cpp: In function ‘void show()’:
prog.cpp:19:9: error: ‘int B::y’ is private
    int y;
        ^
prog.cpp:31:49: error: within this context
    cout << "The default value of B::y = " << b.y;
                                                ^
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
vikas_m07
GauthamRubyseven
anshikajain26
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Set in C++ Standard Template Library (STL)
vector erase() and clear() in C++
unordered_map in C++ STL
Substring in C++
C++ Classes and Objects
Sorting a vector in C++
Priority Queue in C++ Standard Template Library (STL)
2D Vector In C++ With User Defined Size
C++ Data Types
Templates in C++ with Examples
Lodash _.uniqWith() Method

31 Aug, 2020
The _.uniqWith() method is similar to _.uniq() method ( i.e. it creates a duplicate-free version of an array, in which only the first occurrence of each element is kept.) except that it accepts comparator which is invoked to compare elements of an array. Order of result values is determined by the order they occur in the array.
Syntax:
_.uniqWith(array, [comparator])
Parameters: This method accepts two parameters as mentioned above and described below:
array: This parameter holds the array to inspect.
[comparator] (Function): This parameter holds the comparator invoked per element and is invoked with two arguments (arrVal, othVal).
Return Value: This method returns the new duplicate free array.
Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library in the file.
javascript
// Requiring the lodash library const _ = require("lodash");       // Original array var objects = [{ 'x': 5, 'y': 2 }, { 'x': 3, 'y':   4 }, { 'x': 5, 'y': 2 } ];      // Use of _.uniqWith() methodlet gfg = _.uniqWith(objects, _.isEqual);      // Printing the output console.log(gfg);
Output:
[ { x: 5, y: 2 }, { x: 3, y: 4 } ]

Example 2:
javascript
// Requiring the lodash library const _ = require("lodash");       // Original array var objects = [ 2.2, 3.2, 4.2, 3.2, 5.2, 4.2 ];      // Use of _.uniqWith() methodlet gfg = _.uniqWith(objects, _.isEqual);      // Printing the output console.log(gfg);
Output:
[ 2.2, 3.2, 4.2, 5.2]

Example 3:
javascript
// Requiring the lodash library const _ = require("lodash");       // Original array var objects = ['p', 'q', 'r',       'u', 's', 't', 'r', 'u'];      // Use of _.uniqWith() methodlet gfg = _.uniqWith(objects, _.isEqual);      // Printing the output console.log(gfg);
Output:
['p', 'q', 'r', 'u', 's', 't']

Note: This code will not work in normal JavaScript because it requires the library lodash to be installed.
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Display date and time in videos using OpenCV – Python

16 Jul, 2021
OpenCV-Python is a library of Python bindings designed to solve computer vision problems. It can process images and videos to identify objects, faces, or even the handwriting of a humanNote: For more information, refer to Introduction to OpenCV 
It sometimes becomes necessary to display date and time on videos when we are processing videos of live feed or videos which are of a large duration. Time and date will be helpful to know and analyze any anomaly detected in the video with reference to its time and date. To display date and time on videos we do the following.Code  
Python3
# Import librariesimport numpyimport cv2import datetime # open the videovid = cv2.VideoCapture('sample.mp4') # Process until end.while(vid.isOpened()):    ret, frame = vid.read()     if ret:        # describe the type of        # font you want to display        font = cv2.FONT_HERSHEY_SCRIPT_COMPLEX         # Get date and time and        # save it inside a variable        dt = str(datetime.datetime.now())         # put the dt variable over the        # video frame        frame = cv2.putText(frame, dt,                            (10, 100),                            font, 1,                            (210, 155, 155),                            4, cv2.LINE_8)                 # show the video        cv2.imshow('frame', frame)         key = cv2.waitKey(1)                 # define the key to        # close the window        if key == 'q' or key == 27:            break    else:                 break                  # release the vid objectvid.release() # close all the opened windows.cv2.destroyAllWindows()
Output  
 
saurabh1990aror
Python-OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function
Java String join() with examples

04 Dec, 2018
The java.lang.string.join() method concatenates the given elements with the delimiter and returns the concatenated string.Note that if an element is null, then null is added.The join() method is included in java string since JDK 1.8.There are two types of join() methods in java string.Syntax:
public static String join(CharSequence deli, CharSequence... ele)  
and  
public static String join
(CharSequence deli, Iterable<? extends CharSequence> ele)     
Parameters:
deli- delimiter to be attached with each element 
ele- string or char to be attached with delimiter
Returns :  string joined with delimiter.

// Java program to demonstrate// working of join() method  class Gfg1 {    public static void main(String args[])    {        // delimiter is "<" and elements are "Four", "Five", "Six", "Seven"        String gfg1 = String.join(" < ", "Four", "Five", "Six", "Seven");          System.out.println(gfg1);    }}
Output:
Four < Five < Six < Seven

// Java program to demonstrate// working of join() method  class Gfg2 {    public static void main(String args[])    {        // delimiter is "  " and elements are "My",        // "name", "is", "Niraj", "Pandey"        String gfg2 = String.join("  ", "My", "name", "is", "Niraj", "Pandey");          System.out.println(gfg2);    }}
Output:
My name is Niraj Pandey

// Java program to demonstrate// working of join() method  class Gfg3 {    public static void main(String args[])    {        // delimiter is "->" and elements are "Wake up",         // "Eat", "Play", "Sleep", "Wake up"          String gfg3 = String.join("-> ", "Wake up", "Eat",                      "Play", "Sleep", "Wake up");          System.out.println(gfg3);    }}
Output:
Wake up-> Eat-> Play-> Sleep-> Wake up

Java-Functions
Java-lang package
Java-Strings
Java
Java-Strings
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
ArrayList in Java
Stream In Java
Collections in Java
Multidimensional Arrays in Java
Singleton Class in Java
Stack Class in Java
Read/Write structure to a file using C

fwrite() and fread() is used to write to a file in C.
fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
where
ptr - A pointer to array of elements to be written
size - Size in bytes of each element to be written
nmemb - Number of elements, each one with a size of bytes
stream – A pointer to a FILE object that specifies an output stream
fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
where
ptr - A pointer to a block of memory with a minimum size of size*nmemb bytes.
size - Size in bytes of each element to be read.
nmemb - Number of elements, each one with a size of bytes.
stream - A pointer to a FILE object that specifies an input stream.
Begin
   Create a structure Student to declare variables.
   Open file to write.
   Check if any error occurs in file opening.
   Initialize the variables with data.
   If file open successfully, write struct using write method.
      Close the file for writing.
   Open the file to read.
   Check if any error occurs in file opening.
   If file open successfully, read the file using read method.
      Close the file for reading.
   Check if any error occurs.
   Print the data.
End.
This is an example to read/write structure in C:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Student {
   int roll_no;
   char name[20];
};
int main () {
   FILE *of;
   of= fopen ("c1.txt", "w");
   if (of == NULL) {
      fprintf(stderr, "\nError to open the file\n");
      exit (1);
   }
   struct Student inp1 = {1, "Ram"};
   struct Student inp2 = {2, "Shyam"};
   fwrite (&inp1, sizeof(struct Student), 1, of);
   fwrite (&inp2, sizeof(struct Student), 1, of);
   if(fwrite != 0)
      printf("Contents to file written successfully !\n");
   else
      printf("Error writing file !\n");
   fclose (of);
   FILE *inf;
   struct Student inp;
   inf = fopen ("c1.txt", "r");
   if (inf == NULL) {
      fprintf(stderr, "\nError to open the file\n");
      exit (1);
   }
   while(fread(&inp, sizeof(struct Student), 1, inf))
      printf ("roll_no = %d name = %s\n", inp.roll_no, inp.name);
   fclose (inf);
}
Contents to file written successfully !
roll_no = 1 name = Ram
roll_no = 2 name = Shyam
Python – Extract String till Numeric

01 Aug, 2020
Given a string, extract all its content till first appearance of numeric character.
Input : test_str = “geeksforgeeks7 is best”Output : geeksforgeeksExplanation : All characters before 7 are extracted.
Input : test_str = “2geeksforgeeks7 is best”Output : “”Explanation : No character extracted as 1st letter is numeric.
Method #1 : Using isdigit() + index() + loop
The combination of above functions can be used to solve this problem. In this, we check for first occurrence of numeric using isdigit() and index() is used to get required index till which content needs to be extracted.
Python3
# Python3 code to demonstrate working of # Extract String till Numeric# Using isdigit() + index() + loop  # initializing stringtest_str = "geeks4geeks is best"  # printing original stringprint("The original string is : " + str(test_str))  # loop to iterating characterstemp = 0for chr in test_str:        # checking if character is numeric,  # saving index  if chr.isdigit():     temp = test_str.index(chr)  # printing result print("Extracted String : " + str(test_str[0 : temp])) 
The original string is : geeks4geeks is best
Extracted String : geeks

Method #2 : Using regex()
This is yet another way in which this task can be performed. Using appropriate regex(), one can get content before possible numerics.
Python3
# Python3 code to demonstrate working of # Extract String till Numeric# Using regex()import re  # initializing stringtest_str = "geeks4geeks is best"  # printing original stringprint("The original string is : " + str(test_str))  # regex to get all elements before numericsres = re.findall('([a-zA-Z ]*)\d*.*', test_str)  # printing result print("Extracted String : " + str(res[0])) 
The original string is : geeks4geeks is best
Extracted String : geeks

Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Merge two sorted arrays using C++.

Given 2 sorted arrays list. Write a function to merge given two sorted arrays into one
Arr1[] = {10,15, 17, 20}
Arr2[] = {5, 9, 13, 19}
Result[] = {5, 9, 10, 13, 15, 17, 19, 20}
1. Traverse both array
   1.1. If arr1[i] < arr2[j]
      1.1.1. Add arr[i] to new array
      1.1.2. Increment ‘i’ and index of result array ‘k’
   1.2. If arr2[i] < arr1[j]
      1.2.1. Add arr[j] to new array
      1.2.2. Increment ‘j’ and index of result array ‘k’
2. Repeat procedure until both arrays are exhausted
3. Return resultant array
#include <iostream>
#define SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
using namespace std;
void mergeSortedArrays(int *arr1, int n1, int *arr2, int n2, int *result){
   int i, j, k;
   i = 0;
   j = 0;
   k = 0;
   while (i < n1 && j < n2) {
      if (arr1[i] < arr2[j]) {
         result[k] = arr1[i];
         ++k;
         ++i;
      } else {
         result[k] = arr2[j];
         ++k;
         ++j;
      }
   }
   while (i < n1) {
      result[k] = arr1[i];
      ++k;
      ++i;
   }
   while (j < n2) {
      result[k] = arr2[j];
      ++k;
      ++j;
   }
}
void dispalyArray(int *arr, int n){
   for (int i = 0; i < n; ++i) {
      cout << arr[i] << " ";
   }
   cout << endl;
}
int main(){
   int arr1[] = {10, 15, 17, 20};
   int arr2[] = {5, 9, 7, 13, 19};
   int result[SIZE(arr1) + SIZE(arr2)];
   cout << "First sorted array:" << endl;
   dispalyArray(arr1, SIZE(arr1));
   cout << "Second sorted array:" << endl;
   dispalyArray(arr2, SIZE(arr2));
   mergeSortedArrays(arr1, SIZE(arr1), arr2, SIZE(arr2), result);
   cout << "Final sorted array:" << endl;
   dispalyArray(result, SIZE(result));
   return 0;
}
When you compile and execute the above program. It generates the following output −
First sorted array:
10 15 17 20
Second sorted array:
5 9 7 13 19
Final sorted array:
5 9 7 10 13 15 17 19 20
Stack Unwinding in C++

25 Nov, 2021
Stack Unwinding is the process of removing function entries from function call stack at run time. The local objects are destroyed in reverse order in which they were constructed. 
Stack Unwinding is generally related to Exception Handling. In C++, when an exception occurs, the function call stack is linearly searched for the exception handler, and all the entries before the function with exception handler are removed from the function call stack. So, exception handling involves Stack Unwinding if an exception is not handled in the same function (where it is thrown). Basically, Stack unwinding is a process of calling the destructors (whenever an exception is thrown) for all the automatic objects constructed at run time. 
For example, the output of the following program is: 
CPP
// CPP Program to demonstrate Stack Unwinding#include <iostream>using namespace std;  // A sample function f1() that throws an int exceptionvoid f1() throw(int){    cout << "\n f1() Start ";    throw 100;    cout << "\n f1() End ";}  // Another sample function f2() that calls f1()void f2() throw(int){    cout << "\n f2() Start ";    f1();    cout << "\n f2() End ";}  // Another sample function f3() that calls f2() and handles// exception thrown by f1()void f3(){    cout << "\n f3() Start ";    try {        f2();    }    catch (int i) {        cout << "\n Caught Exception: " << i;    }    cout << "\n f3() End";}  // Driver Codeint main(){    f3();      getchar();    return 0;}
 f3() Start 
 f2() Start 
 f1() Start 
 Caught Exception: 100
 f3() End
Explanation:
When f1() throws exception, its entry is removed from the function call stack, because f1() doesn’t contain exception handler for the thrown exception, then next entry in call stack is looked for exception handler.
The next entry is f2(). Since f2() also doesn’t have a handler, its entry is also removed from the function call stack.
The next entry in the function call stack is f3(). Since f3() contains an exception handler, the catch block inside f3() is executed, and finally, the code after the catch block is executed.
 Note that the following lines inside f1() and f2() are not executed at all. 
 cout<<"\n f1() End ";  // inside f1()

 cout<<"\n f2() End ";  // inside f2()
If there were some local class objects inside f1() and f2(), destructors for those local objects would have been called in the Stack Unwinding process.
Note: Stack Unwinding also happens in Java when exception is not handled in same function. 
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
anshikajain26
C++-Exception Handling
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How can we split a string by sentence as a delimiter in Java?

The split() method of the String class accepts a String value representing the delimiter and splits into an array of tokens (words), treating the string between the occurrence of two delimiters as one token.
For example, if you pass single space “ ” as a delimiter to this method and try to split a String. This method considers the word between two spaces as one token and returns an array of words (between spaces) in the current String.
If the String does not contain the specified delimiter this method returns an array containing the whole string as an element.
 Live Demo
public class SplitExample {
   public static void main(String[] args) {
      String str = "Hi how are you welcome to Tutorialspoint";
      String words[] = str.split(" ");
      for(String token : words) {
         System.out.println(token);
      }
   }
}
Hi
how
are
you
welcome
to
Tutorialspoint
You can also split a sentence by passing a sentence as a delimiter if you do so each time the specified sentence occurs the String is divided as a separate token.
Following Java program reads the contents of a file into a Sting and splits it using the split() method with a sentence as a delimiter.
public class StringOccurrence {
   public static String fileToString(String filePath){
      Scanner sc = null;
      String input = null;
      StringBuffer sb = null;
      try {
         sc = new Scanner(new File(filePath));
         sb = new StringBuffer();
         while (sc.hasNextLine()) {
            input = sc.nextLine();
            sb.append(" "+input);
         }
      }
      catch(Exception ex) {
         ex.toString();
      }
      return sb.toString();
   }
   public static void main(String args[]) throws FileNotFoundException {
      String filePath = "D://sampleData.txt";
      String text = fileToString(filePath);
      String array[] = text.split("We don’t force our readers to sign up with us or submit their details either");
      for(String token : array) {
         System.out.println(" ");
         System.out.println(token);
      }
   }
}
Tutorials Point originated from the idea that there exists a class of readers 
who respond better to online content and prefer to learn new skills at their 
own pace from the comforts of their drawing rooms. The journey commenced with 
a single tutorial on HTML in 2006 and elated by the response it generated, 
we worked our way to adding fresh tutorials to our repository which now 
proudly flaunts a wealth of tutorials and allied articles on topics ranging 
from programming languages to web designing to academics and much more. 
40 million readers read 100 million pages every month. Our content and 
resources are freely available and we prefer to keep it that way to 
encourage our readers acquire as many skills as they would like to.
No preconditions and no impediments. Simply Easy Learning!
Angular 8 - Installation

This chapter explains about how to install Angular 8 on your machine. Before moving to the installation, let’s verify the prerequisite first.
As we know already, Angular is written in TypeScript. We need Node and npm to compile the files into JavaScript after that, we can deploy our application. For this purpose, Node.js must be installed in your system. Hopefully, you have installed Node.js on your machine.
We can check it using the below command −
node --version

You could see the version of node. It is show below −
v14.2.0

If Node is not installed, you can download and install by visiting the following link −
Angular 8 CLI installation is based on very simple steps. It will take not more than five minutes to install.
npm is used to install Angular 8 CLI. Once Node.js is installed, npm is also installed. If you want verify it, type the below command
npm -v

You could see the version below −
6.14.4

Let’s install Angular 8 CLI using npmas follows −
npm install -g @angular/cli@^8.0.0

To verify Angular 8 is properly installed on your machine, type the below command −
ng version

You could see the following response −
Angular CLI: 8.3.26 
Node: 14.2.0 
OS: win32 x64 
Angular: ... 
Package                    Version 
------------------------------------------------------
@angular-devkit/architect  0.803.26 
@angular-devkit/core       8.3.26 
@angular-devkit/schematics 8.3.26 
@schematics/angular        8.3.26 
@schematics/update         0.803.26 
rxjs                       6.4.0


    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
How to preload the video when the page loads in HTML5 ? - GeeksforGeeks

25 Mar, 2021
The HTML <preload> attribute is used to specify the way the developer thinks the video should be loaded when the page loads.
Syntax
<video preload=""> </video>
There are 3 values for preload attribute auto, metadata and none.
Note: A empty string lead to default auto attribute value.
Example 1: The following example demonstrates the video element using none attribute value for the preload property.
HTML
<!DOCTYPE html> <html>  <body>     <center>         <h1 style="color:green;">GeeksforGeeks</h1>           <h3>HTML preload Attribute</h3>           <video width="400" height="200" controls preload="none">             <source src= "https://media.geeksforgeeks.org/wp-content/uploads/20190616234019/Canvas.move_.mp4"                    type="video/mp4">             <source src= "https://media.geeksforgeeks.org/wp-content/uploads/20190616234019/Canvas.move_.ogg"                    type="video/ogg">         </video>     </center> </body>   </html> 
Output:
preload with none value
Example 2: The following example demonstrates the video element using auto attribute value.
HTML
<!DOCTYPE html> <html> <body>     <center>         <h1 style="color:green;">GeeksforGeeks</h1>           <h3>HTML preload Attribute</h3>           <video width="400" height="200" controls preload="auto">             <source src= "https://media.geeksforgeeks.org/wp-content/uploads/20190616234019/Canvas.move_.mp4"                    type="video/mp4">             <source src= "https://media.geeksforgeeks.org/wp-content/uploads/20190616234019/Canvas.move_.ogg"                    type="video/ogg">         </video>     </center> </body>   </html> 
Output:
preload with auto value
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML-Questions
HTML-Tags
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
Types of CSS (Cascading Style Sheet)
Form validation using HTML and JavaScript
How to position a div at the bottom of its container using CSS?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
array-of- arrays double [][] in C#?

Arrays of arrays in C# are known as Jagged Arrays. To declare jagged arrays, use the double [ ][ ].
Let us now declare them −
int [][] marks;
Now, let us initialize it, wherein marks are arrays of 5 integers −
int[][] marks = new int[][]{new int[]{ 90,95 },new int[]{ 89,94 }, new int[]{ 78,87 },new int[]{ 76, 68 }, new
int[]{ 98, 91 } };
Let us now see the complete example of jagged arrays in C# and learn how to implement it −
Live Demo
using System;
namespace MyApplication {
   class MyDemoClass {
      static void Main(string[] args) {
         int i, j;
         /* jagged array of 5 array of integers */
         int[][] marks = new int[][]{new int[]{90,95},new int[]{89,94}, new int[]{78,87},new int[]{ 76, 68 },
         new int[]{ 98, 91}};

         for (i = 0; i < 5; i++) {
            for (j = 0; j < 2; j++) {
               Console.WriteLine("marks[{0}][{1}] = {2}", i, j, marks[i][j]);
            }
         }
         Console.ReadKey();
      }
   }
}
marks[0][0] = 90
marks[0][1] = 95
marks[1][0] = 89
marks[1][1] = 94
marks[2][0] = 78
marks[2][1] = 87
marks[3][0] = 76
marks[3][1] = 68
marks[4][0] = 98
marks[4][1] = 91
PHP program to find the minimum element in an array

To find the minimum element in an array, the PHP code is as follows −
 Live Demo
<?php
   function get_min_value($my_array){
      $n = count($my_array);
      $min_val = $my_array[0];
      for ($i = 1; $i < $n; $i++)
         if ($min_val > $my_array[$i])
            $min_val = $my_array[$i];
            return $min_val;
   }
   $my_array = array(56, 78, 91, 44, 0, 11);
   print_r("The lowest value of the array is ");
   echo(get_min_value($my_array));
   echo("\n");
?>
The lowest value of the array is 0
A function named ‘get_min_value()’ takes an array as parameter. Inside this function, the count
function is used to find the number of elements in the array, and it is assigned to a variable −
$n = count($my_array);
The first element in the array is assigned to a variable, and the array is iterated over, and adjacent
values in the array are compared, and the lowest value amongst all of them is given as output −
$min_val = $my_array[0];
for ($i = 1; $i < $n; $i++)
   if ($min_val > $my_array[$i])
      $min_val = $my_array[$i];
return $min_val;
Outside the function, the array is defined, and the function is called by passing this array as a
parameter. The output is displayed on the screen.
$my_array = array(56, 78, 91, 44, 0, 11);
print_r("The lowest value of the array is ");
echo(get_min_value($my_array));
How to create comma separated list from an array in PHP?

To create a comma-separated list from an array in PHP, the code is as follows−
 Live Demo
<?php
   $arr = array( " John ", "Jacob ", " Tom ", " Tim ");
   echo "Array with leading and trailing whitespaces...\n";
   foreach( $arr as $value ) {
      echo "Value = $value \n";
   }
   echo "\nComma separated list...\n";
   print_r(implode(', ', $arr));
   $result = array_map('trim', $arr);
   echo "\nUpdated Array...\n";
   foreach( $result as $value ) {
      echo "Value = $value \n";
   }
?>
This will produce the following output−
Array with leading and trailing whitespaces...
Value = John
Value = Jacob
Value = Tom
Value = Tim
Comma separated list...
   John , Jacob , Tom , Tim
Updated Array...
Value = John
Value = Jacob
Value = Tom
Value = Tim
Let us now see another example −
 Live Demo
<?php
   $arr = array(100, 200, 300, 400, 500);
   echo "Comma separated list...\n";
   print_r(implode(', ', $arr));
?>
This will produce the following output−
Comma separated list... 
100, 200, 300, 400, 500
Are Multiple Constructors possible in Java?

There can be multiple constructors in a class. However, the parameter list of the constructors should not be same. This is known as constructor overloading.
A program that demonstrates this is given as follows −
 Live Demo
class NumberValue {
   private int num;
   public NumberValue() {
      num = 6;
   }
   public NumberValue(int n) {
      num = n;
   }
   public void display() {
      System.out.println("The number is: " + num);
   }
}
public class Demo {
   public static void main(String[] args) {
      NumberValue obj1 = new NumberValue();
      NumberValue obj2 = new NumberValue(15);
      obj1.display();
      obj2.display();
   }
}
The number is: 6
The number is: 15
Now let us understand the above program.
The NumberValue class is created with a data member num and single member function display() that displays the value of num. There are two constructors in class NumberValue where one of these takes no parameters and the other takes a single parameter of type int. A code snippet which demonstrates this is as follows −
class NumberValue {
   private int num;
   public NumberValue() {
      num = 6;
   }
   public NumberValue(int n) {
      num = n;
   }
   public void display() {
      System.out.println("The number is: " + num);
   }
}
In the main() method, objects obj1 and obj2 of class NumberValue are created and the display() method is called for both of them. A code snippet which demonstrates this is as follows:
public class Demo {
   public static void main(String[] args) {
      NumberValue obj1 = new NumberValue();
      NumberValue obj2 = new NumberValue(15);
      obj1.display();
      obj2.display();
   }
}
Python - Remove empty value types in dictionaries list - GeeksforGeeks

08 May, 2020
Sometimes, while working with Python dictionaries, we require to remove all the values that are virtually Null, i.e does not hold any meaningful value and are to be removed before processing data, this can be empty string, empty list, dictionary or even 0. This has application in data preprocessing. Lets discuss certain ways in which this task can be performed.
Method #1 : Using list comprehensionThis is shorthand to brute way by which this task can be performed. In this we remake the dictionary with only the valid values.
# Python3 code to demonstrate working of # Remove None value types in dictionaries list# Using list comprehension  # initializing listtest_list = [{'gfg' : 4, 'is' : '', 'best' : []}, {'I' : {}, 'like' : 5, 'gfg' : 0}]  # printing original listprint("The original list is : " + str(test_list))  # Remove None value types in dictionaries list# Using list comprehensionres = [ele for ele in ({key: val for key, val in sub.items() if val} for sub in test_list) if ele]                                         # printing result print("The filtered list : " + str(res)) 
The original list is : [{'is': '', 'best': [], 'gfg': 4}, {'like': 5, 'gfg': 0, 'I': {}}]
The filtered list : [{'gfg': 4}, {'like': 5}]

 
Method #2 : Using filter() + lambda + list comprehensionThe combination of above methods can be used to solve this problem. In this, we use filter() + lambda to perform the conditional statement task as in above method to reduce a nesting level.
# Python3 code to demonstrate working of # Remove None value types in dictionaries list# Using filter() + lambda + list comprehension  # initializing listtest_list = [{'gfg' : 4, 'is' : '', 'best' : []}, {'I' : {}, 'like' : 5, 'gfg' : 0}]  # printing original listprint("The original list is : " + str(test_list))  # Remove None value types in dictionaries list# Using filter() + lambda + list comprehensionres = list(filter(None, ({key : val for key, val in sub.items() if val} for sub in test_list)))                                         # printing result print("The filtered list : " + str(res)) 
The original list is : [{'is': '', 'best': [], 'gfg': 4}, {'like': 5, 'gfg': 0, 'I': {}}]
The filtered list : [{'gfg': 4}, {'like': 5}]

Python list-programs
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Enumerate() in Python
Read a file line by line in Python
Defaultdict in Python
Different ways to create Pandas Dataframe
sum() function in Python
Iterate over a list in Python
Deque in Python
How to Install PIP on Windows ?
Python String | replace()
Convert integer to string in Python
How to search for a pattern in a Java string?

Java provides the java.util.regex package for pattern matching with regular expressions. You can then search for a pattern in a Java string using classes and methods of this packages.
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexMatches {
   public static void main( String args[] ) {

      String line = "This order was placed for QT3000! OK?";
      String pattern = "(.*)(\\d+)(.*)";
      Pattern r = Pattern.compile(pattern);
      Matcher m = r.matcher(line);
     
      if (m.find( )) {
         System.out.println("Found value: " + m.group(0));
         System.out.println("Found value: " + m.group(1));
         System.out.println("Found value: " + m.group(2));
      }else{
         System.out.println("NO MATCH");
      }
   }
}
Found value: This order was placed for QT3000! OK?
Found value: This order was placed for QT300
Found value: 0
Image processing/OpenCV image erosion Java Example.

Erosion and dilation are the two basic morphological operations. As the name
implies, morphological operations are the set of operations that process images
according to their shapes.
During erosion operation, additional pixels are removed from image boundaries,
total number of pixels removed during the erosion process depends on the
dimensions of the structuring element used.
You can perform erosion operation on an image using the erode() method of the Imgproc class, this method three mat objects representing source, destination, and kernel.
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javafx.application.Application;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.image.WritableImage;
import javafx.stage.Stage;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class ImageErosion extends Application {
   public void start(Stage stage) throws IOException {
      //Loading the OpenCV core library
      System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
      //Reading image data
      String file ="D:\\Images\\lamma2.jpg";
      Mat src = Imgcodecs.imread(file);
      //Creating destination matrix
      Mat dst = new Mat(src.rows(), src.cols(), src.type());
      //Preparing the kernel matrix object
      Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size((2*2) + 1, (2*2)+1));
      //Applying erosion on the Image
      Imgproc.erode(src, dst, kernel);
      //Converting matrix to JavaFX writable image
      Image img = HighGui.toBufferedImage(dst);
      WritableImage writableImage= SwingFXUtils.toFXImage((BufferedImage) img, null);
      //Setting the image view
      ImageView imageView = new ImageView(writableImage);
      imageView.setX(10);
      imageView.setY(10);
      imageView.setFitWidth(575);
      imageView.setPreserveRatio(true);
      //Setting the Scene object
      Group root = new Group(imageView);
      Scene scene = new Scene(root, 595, 400);
      stage.setTitle("Erosion Example");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]) {
      launch(args);
   }
}
On executing, the above program generates the following output −
How can we create the MySQL view with ORDER BY clause?

We can use MySQL ORDER BY clause to sort the records in our result set. . To understand GROUP BY clause with views we are creating a view named ‘Info’ using the base table ‘Student_info’ having the following data −
mysql> Select * from Student_info;
+------+---------+------------+------------+
| id   | Name    | Address    | Subject    |
+------+---------+------------+------------+
| 101  | YashPal | Amritsar   | History    |
| 105  | Gaurav  | Chandigarh | Literature |
| 125  | Raman   | Shimla     | Computers  |
| 130  | Ram     | Jhansi     | Computers  |
| 132  | Shyam   | Chandigarh | Economics  |
| 133  | Mohan   | Delhi      | Computers  |
+------+---------+------------+------------+
6 rows in set (0.00 sec)
Create or Replace View view_name AS Select_statements FROM table ORDER BY expression [ASC|DESC]
mysql> Create or Replace View Info AS select ID, Name, Address , Subject FROM Student_info ORDER BY Name ASC;
Query OK, 0 rows affected (0.11 sec)

mysql> Select * from info;
+------+---------+------------+------------+
| ID   | Name    | Address    | Subject    |
+------+---------+------------+------------+
| 105  | Gaurav  | Chandigarh | Literature |
| 133  | Mohan   | Delhi      | Computers  |
| 130  | Ram     | Jhansi     | Computers  |
| 125  | Raman   | Shimla     | Computers  |
| 132  | Shyam   | Chandigarh | Economics  |
| 101  | YashPal | Amritsar   | History    |
+------+---------+------------+------------+
6 rows in set (0.00 sec)

mysql> Create or Replace View Info AS select ID, Name, Address , Subject FROM Student_info ORDER BY Name DESC;
Query OK, 0 rows affected (0.10 sec)

mysql> Select * from info;
+------+---------+------------+------------+
| ID   | Name    | Address    | Subject    |
+------+---------+------------+------------+
| 101  | YashPal | Amritsar   | History    |
| 132  | Shyam   | Chandigarh | Economics  |
| 125  | Raman   | Shimla     | Computers  |
| 130  | Ram     | Jhansi     | Computers  |
| 133  | Mohan   | Delhi      | Computers  |
| 105  | Gaurav  | Chandigarh | Literature |
+------+---------+------------+------------+
6 rows in set (0.00 sec)