code-rag-bench/online-tutorials huggingface dataset:
POJI in Java

05 May, 2021
POJI: stands for Plain Old Java Interface. A POJI is an ordinary interface without any specialties. The interfaces that do not extend from technology/framework specific interfaces. For example all user defined interfaces are POJI and an interface that inherits from AppletInitializer of Java Beans is not POJI.Examples:
JAVA
// A POJI interfaceinterface GFG {  public void method1();} interface Geeks extends GFG {  public void method2();}
Explanation: Here both the interfaces i.e. GFG and Geeks are POJI in nature. Because both GFG and Geeks does not extends from any technology specific interface.    
JAVA
// Another POJI interfaceinterface GFG extends java.io.Serializable { }
Explanation: Here GFG is also a POJI. Here the interface is extending from Serializable interface but that serializable interface is not the part of any Technology, it is about Java API. Therefore, we can say that GFG is POJI in nature.    
JAVA
// Not a POJI Interfaceinterface GFG1 extends java.rmi.Remote { } // Not a POJI Interfaceinterface GFG2 extends java.beans.AppletInitializer { }
Explanation: Here GFG1 and GFG2 are not POJI in nature. Because Remote and AppletInitializer not part of API, it is technology. 
hritikbhatnagar2182
java-interfaces
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | os.remove() method

29 May, 2019
OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
All functions in os module raise OSError in the case of invalid or inaccessible file names and paths, or other arguments that have the correct type, but are not accepted by the operating system.
os.remove() method in Python is used to remove or delete a file path. This method can not remove or delete a directory. If the specified path is a directory then OSError will be raised by the method. os.rmdir() can be used to remove directory.
Syntax: os.remove(path, *, dir_fd = None)
Parameter:path: A path-like object representing a file path. A path-like object is either a string or bytes object representing a path.dir_fd (optional) : A file descriptor referring to a directory. The default value of this parameter is None.If the specified path is absolute then dir_fd is ignored.
Note: The ‘*’ in parameter list indicates that all following parameters (Here in our case ‘dir_fd’) are keyword-only parameters and they can be provided using their name, not as positional parameter.
Return Type: This method does not return any value.
# Python program to explain os.remove() method     # importing os module import os  # File namefile = 'file.txt'  # File locationlocation = "/home/User/Documents"  # Pathpath = os.path.join(location, file)  # Remove the file# 'file.txt'os.remove(path)print("%s has been removed successfully" %file)
file.txt has been removed successfully

# Python program to explain os.remove() method     # importing os module import os  # Pathpath = "/home/User/Documents/ihritik"  # Remove the specified# file pathos.remove(path)print("% s has been removed successfully" % file)  # if the specified path # is a directory then # 'IsADirectoryError' error# will raised   # Similarly if the specified# file path does not exists or  # is invalid then corresponding# OSError will be raised
Traceback (most recent call last):
  File "osremove.py", line 11, in 
    os.remove(path)
IsADirectoryError: [Errno 21] Is a directory: '/home/User/Documents/ihritik'

# Python program to explain os.remove() method     # importing os module import os  # pathpath = '/home/User/Documents/ihritik'  # Remove the specified # file pathtry:    os.remove(path)    print("% s removed successfully" % path)except OSError as error:    print(error)    print("File path can not be removed")
[Errno 21] Is a directory: '/home/User/Documents/ihritik'
File path can not be removed

Reference: https://docs.python.org/3/library/os.html
Python OS-path-module
python-os-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Handling NameError Exception in Python

29 Jan, 2022
Prerequisites: Python Exception Handling
There are several standard exceptions in Python and NameError is one among them. NameError is raised when the identifier being accessed is not defined in the local or global scope. General causes for NameError being raised are :
1. Misspelled built-in functions:
In the below example code, the print statement is misspelled hence NameError will be raised.
Python3
geek = input()print(geek)
Output : 
NameError: name 'print' is not defined
2. Using undefined variables:
When the below program is executed, NameError will be raised as the variable geek is never defined.
Python3
geeky = input()print(geek)
 Output : 
NameError: name 'geek' is not defined
3. Defining variable after usage:
In the following example, even though the variable geek is defined in the program, it is defined after its usage. Since Python interprets the code from top to bottom, this will raise NameError
Python3
print(geek)geek = "GeeksforGeeks"
 Output : 
NameError: name 'geek' is not defined
4. Incorrect usage of scope:
In the below example program, the variable geek is defined within the local scope of the assign function. Hence, it cannot be accessed globally. This raises NameError.
Python3
def assign():    geek = "GeeksforGeeks" assign()print(geek)
 Output : 
NameError: name 'geek' is not defined
To specifically handle NameError in Python, you need to mention it in the except statement. In the following example code, if only the NameError is raised in the try block then an error message will be printed on the console.
Python3
def geek_message():    try:        geek = "GeeksforGeeks"        return geeksforgeeks    except NameError:        return "NameError occurred. Some variable isn't defined." print(geek_message())
Output : 
NameError occurred. Some variable isn't defined.
saurabh1990aror
sumitgumber28
Python-exceptions
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
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
Introduction To PYTHON
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
How to use Docker Default Bridge Networking?

05 Nov, 2020
Docker allows you to create dedicated channels between multiple Docker Containers to create a network of Containers that can share files and other resources with each other. This is called Docker Networking. You can create Docker Networks with various kinds of Network Drivers which include Bridge drivers, McVLAN drivers, etc. By default, if you do not mention a driver while creating a network, it automatically chooses the default bridge driver. Bridge drivers are single-host networking drivers and hence their scope is limited to local.
In this article, we are going to discuss how to create, manage, and use Docker Bridge Networks. For this, you would need a Linux based Host machine with access to Docker. Without any further ado, let’s dive deep into Docker Bridged Networking.
Every installation of Docker provides a pre-built default Bridge Network with Bridge driver scoped locally. You can verify the same using the network ls command.
sudo docker network ls


Bridge Driver always provides single-host networking hence, the scope is local.
Note that the Bridge Network we saw in the previous step is the default network for Docker Containers. If you don’t specify any other network, all new Containers will be joined to this default network. To connect an Ubuntu Container to the default bridge network, use this command.
sudo docker run -dt ubuntu 


After you have created the Docker Container, check whether it is running or not.
sudo docker container ls


Since the Container is already running, we can now use the network inspect command to inspect the Docker default bridge network.
sudo docker network inspect bridge


You can see the details related to the Bridge Network in JSON format. You can also check the Containers associated with the network in the Container object.
To test the network connectivity, note down the IP address of the Container. In this example, the IP address is “172.17.0.2/16”.
We will ping this address from the Docker Host to check the connectivity.
ping 172.17.0.2


It shows that the host is able to ping the Docker Container in the network.
Docker Container
linux
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Monte Carlo Tree Search (MCTS)
Markov Decision Process
Basics of API Testing Using Postman
Copying Files to and from Docker Containers
Getting Started with System Design
Principal Component Analysis with Python
How to create a REST API using Java Spring Boot
Fuzzy Logic | Introduction
Monolithic vs Microservices architecture
OpenCV - Overview
Selenium - Multi Select Action

Sometimes we would be in a situation to select two or more items in a list box or text area. To understand the same, we would demonstrate multiple selection from the list using 'https://demos.devexpress.com/aspxeditorsdemos/ListEditors/MultiSelect.aspx'.
Let us say, we want to select 3 items from this list as shown below -
Let us see how to code for this functionality −
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.interactions.Action;

public class webdriverdemo {

   public static void main(String[] args) throws InterruptedException {
   
      WebDriver driver = new FirefoxDriver();
      driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

      driver.navigate().to("http://demos.devexpress.com/aspxeditorsdemos/ListEditors/MultiSelect.aspx");

      //driver.manage().window().maximize();
      driver.findElement(By.id("ContentHolder_lbSelectionMode_I")).click();
      driver.findElement(By.id("ContentHolder_lbSelectionMode_DDD_L_LBI1T0")).click();
      Thread.sleep(5000);
      
      // Perform Multiple Select
      Actions builder = new Actions(driver);
      WebElement select = driver.findElement(By.id("ContentHolder_lbFeatures_LBT"));
      List<WebElement> options = select.findElements(By.tagName("td"));
      
      System.out.println(options.size());
      Action multipleSelect = 
         builder.keyDown(Keys.CONTROL).click(options.get(2)).click(options.get(4)).click(options.get(6)).build();
      
      multipleSelect.perform();
      driver.close();
   }
}
Upon executing the script, the items would be selected as displayed above and the size of the list box would also be printed in the console.
SymPy - Symbols

Symbol is the most important class in symPy library. As mentioned earlier, symbolic computations are done with symbols. SymPy variables are objects of Symbols class.
Symbol() function's argument is a string containing symbol which can be assigned to a variable.
>>> from sympy import Symbol 
>>> x=Symbol('x') 
>>> y=Symbol('y') 
>>> expr=x**2+y**2 
>>> expr

The above code snippet gives an output equivalent to the below expression −
x2+y2
A symbol may be of more than one alphabets.
>>> s=Symbol('side') 
>>> s**3

The above code snippet gives an output equivalent to the below expression −
side3
SymPy also has a Symbols() function that can define multiple symbols at once. String contains names of variables separated by comma or space.
>>> from sympy import symbols 
>>> x,y,z=symbols("x,y,z")

In SymPy's abc module, all Latin and Greek alphabets are defined as symbols. Hence, instead of instantiating Symbol object, this method is convenient.
>>> from sympy.abc import x,y,z

However, the names C, O, S, I, N, E and Q are predefined symbols. Also, symbols with more than one alphabets are not defined in abc module, for which you should use Symbol object as above. The abc module defines special names that can detect definitions in default SymPy namespace. clash1 contains single letters and clash2 has multi letter clashing symbols
>>> from sympy.abc import _clash1, _clash2 
>>> _clash1

The output of the above snippet is as follows −
{'C': C, 'O': O, 'Q': Q, 'N': N, 'I': I, 'E': E, 'S': S}
>>> _clash2

The output of the above snippet is as follows −
{'beta': beta, 'zeta': zeta, 'gamma': gamma, 'pi': pi}
Indexed symbols can be defined using syntax similar to range() function. Ranges are indicated by a colon. Type of range is determined by the character to the right of the colon. If itr is a digit, all contiguous digits to the left are taken as the nonnegative starting value. All contiguous digits to the right are taken as 1 greater than the ending value.
>>> from sympy import symbols 
>>> symbols('a:5')

The output of the above snippet is as follows −
(a0, a1, a2, a3, a4)
>>> symbols('mark(1:4)')

The output of the above snippet is as follows −
(mark1, mark2, mark3)
 Print
 Add Notes
 Bookmark this page
isspace() function in C++

The isspace() function is a predefined function in ctype.h. It specifies whether the argument is a whitespace character or not. Some of the whitespace characters are space, horizontal tab, vertical tab etc.
A program that implements isspace() function by counting the number of spaces in a string is given as follows −
 Live Demo
#include <iostream>
#include <ctype.h>

using namespace std;
int main() {
   char str[] = "Coding is fun";
   int i, count = 0;

   for(i=0; str[i]!='\0';i++) {
      if(isspace(str[i]))
      count++;
   }

   cout<<"Number of spaces in the string are "<<count;
   return 0;
}
The output of the above program is as follows −
Number of spaces in the string are 2
In the above program, first the string is defined. Then a for loop is used to check each of the characters in the string to see if they are a white space character. If they are, then count is incremented by 1. Finally, the value of count is displayed. This is displayed in the following code snippet −
char str[] = "Coding is fun";
int i, count = 0;

for(i=0; str[i]!='\0';i++) {
   if(isspace(str[i]))
   count++;
}
cout<<"Number of spaces in the string are "<<count;
This is another program to demonstrate the isspace() function. It specifies if the given character is a whitespace character or not. The program is given as follows −
 Live Demo
#include <iostream>
#include <ctype.h>

using namespace std;
int main() {
   char ch1 = 'A';
   char ch2 = ' ';
   if(isspace(ch1))
   cout<<"ch1 is a space"<<endl;

   else
   cout<<"ch1 is not a space"<<endl;
   
   if(isspace(ch2))
   cout<<"ch2 is a space"<<endl;

   else
   cout<<"ch2 is not a space"<<endl;
   return 0;
}
The output of the above program is as follows −
ch1 is not a space
ch2 is a space
In the above program, ch1 and ch2 are defined. Then isspace() is used to check if they are whitespace characters or not. The code snippet for this is given as follows −
char ch1 = 'A';
char ch2 = ' ';

if(isspace(ch1))
cout<<"ch1 is a space"<<endl;

else
cout<<"ch1 is not a space"<<endl;

if(isspace(ch2))
cout<<"ch2 is a space"<<endl;

else
cout<<"ch2 is not a space"<<endl;
Logical Operators on String in Java

Let us implement logical operators on String in Java −
 Live Demo
import java.io.*;
public class Demo{
   public static void main(String[] args){
      int a = 45, b = 32, c = 87, d = 1;
      System.out.println("The first variable is " + a);
      System.out.println("The second variable is = " + b);
      System.out.println("The third variable is = " + c);
      if ((a > b) && (b == c)){
         d = a + b + c;
         System.out.println("The sum is " + d);
      }
      else
         System.out.println("The conditions haven't been fulfilled");
   }
}
The first variable is 45
The second variable is = 32
The third variable is = 87
The conditions haven't been fulfilled
A class named Demo contains the main function, where 4 variables are declared, and various logical
operators are implemented using these variables, and they are declared on the console.
How to iterate over a Java list?

Often, you will want to cycle through the elements in a collection. For example, you might want to display each element.
The easiest way to do this is to employ an iterator, which is an object that implements either the Iterator or the ListIterator interface.
Iterator enables you to cycle through a collection, obtaining or removing elements. ListIterator extends Iterator to allow bidirectional traversal of a list and the modification of elements.
Before you can access a collection through an iterator, you must obtain one. Each of the collection classes provides an iterator() method that returns an iterator to the start of the collection. By using this iterator object, you can access each element in the collection, one element at a time.
In general, to use an iterator to cycle through the contents of a collection, follow these steps −
Obtain an iterator to the start of the collection by calling the collection's iterator() method.Set up a loop that makes a call to hasNext(). Have the loop iterate as long as hasNext() returns true.Within the loop, obtain each element by calling next().
Obtain an iterator to the start of the collection by calling the collection's iterator() method.
Set up a loop that makes a call to hasNext(). Have the loop iterate as long as hasNext() returns true.
Within the loop, obtain each element by calling next().
 Live Demo
import java.util.ArrayList;
import java.util.Iterator;

public class IteratorSample {
   public static void main(String[] args) {
      ArrayList<String> list = new ArrayList<String>();
      list.add("JavaFx");
      list.add("Java");
      list.add("WebGL");
      list.add("OpenCV");
      Iterator iterator = list.iterator();
      while(iterator.hasNext()) {
         System.out.println(iterator.next());
      }
   }
}
JavaFx
Java
WebGL
OpenCV
C library function - isalpha()

The C library function int isalpha(int c) checks if the passed character is alphabetic.
Following is the declaration for isalpha() function.
int isalpha(int c);
c − This is the character to be checked.
c − This is the character to be checked.
This function returns non-zero value if c is an alphabet, else it returns 0.
The following example shows the usage of isalpha() function.
#include <stdio.h>
#include <ctype.h>

int main () {
   int var1 = 'd';
   int var2 = '2';
   int var3 = '\t';
   int var4 = ' ';
    
   if( isalpha(var1) ) {
      printf("var1 = |%c| is an alphabet\n", var1 );
   } else {
      printf("var1 = |%c| is not an alphabet\n", var1 );
   }
   
   if( isalpha(var2) ) {
      printf("var2 = |%c| is an alphabet\n", var2 );
   } else {
      printf("var2 = |%c| is not an alphabet\n", var2 );
   }
   
   if( isalpha(var3) ) {
      printf("var3 = |%c| is an alphabet\n", var3 );
   } else {
      printf("var3 = |%c| is not an alphabet\n", var3 );
   }
   
   if( isalpha(var4) ) {
      printf("var4 = |%c| is an alphabet\n", var4 );
   } else {
      printf("var4 = |%c| is not an alphabet\n", var4 );
   }
   
   return(0);
}
Let us compile and run the above program, to produce the following result −
var1 = |d| is an alphabet                                                   
var2 = |2| is not an alphabet                                               
var3 = |        | is not an alphabet                                        
var4 = | | is not an alphabet  


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
Variables in Scala

31 Oct, 2021
Variables are simply storage locations. Every variable is known by its name and stores some known and unknown piece of information known as value. So one can define a variable by its data type and name, a data type is responsible for allocating memory for the variable. In Scala there are two types of variables: 
Mutable Variables
Immutable Variables
Let’s understand each one of these variables in detail. 
Mutable Variable: These variables are those variables that allow us to change a value after the declaration of a variable. Mutable variables are defined by using the var keyword. The first letter of data type should be in capital letter because in Scala data type is treated as objects. Syntax:  
var Variable_name: Data_type = "value";
For Example: 
var name: String = "geekforgeeks";
Here, name is the name of the variable, string is the data type of variable and geeksforgeeks is the value that store in the memory. Another way of defining variable: 
Syntax: 
var variable_name = value
For Example: 
var value = 40 
//it works without error value = 32
 Here, the value is the name of the variable. 
Immutable Variable: These variables are those variables that do not allow you to change a value after the declaration of a variable. Immutable variables are defined by using the val keyword. The first letter of data type should be in capital letter because in Scala data type is treated as objects. 
Syntax: 
val Variable_name: Data_type =  "value";
For Example: 
val name: String = "geekforgeeks";
Here, a name is the name of the variable, a string is the data type of variable and geeksforgeeks is the value that store in the memory. Another way of defining variable: 
Syntax: 
val variable_name = "value"
For Example: 
val value = 40 
//it will give an error value = 32
 Here value is the name of the variable. 
Rules for naming variable in Scala 
Variable name should be in lower case.
Variable name can contain letter, digit and two special characters(Underscore(_) and Dollar($) sign)
Variable name must not contain the keyword or reserved word.
Starting letter of the variable name should be an alphabet.
White space is not allowed in variable name.
Note: Scala supports multiple assignments but you can use multiple assignments only with immutable variables.For Example: 
val(name1:Int, name2:String) = pair(2, "geekforgeeks")
Variable Type Inference In Scala: Scala supports variable type inference. In variable type inference values are directly assigned to the variable without defining its data type, the Scala compiler automatically resolves which value belongs to which data type. 
For Example: 
var name1=40;
val name2="geeksforgeeks";
Here, name1 is by default int type and name2 is by default string type. 
sujayshashank
nikhildhimanntpc
Scala
Scala-Basics
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
sys.path in Python

01 Oct, 2020
Sys is a built-in Python module that contains parameters specific to the system i.e. it contains variables and methods that interact with the interpreter and are also governed by it. 
sys.path is a built-in variable within the sys module. It contains a list of directories that the interpreter will search in for the required module. 
When a module(a module is a python file) is imported within a Python file, the interpreter first searches for the specified module among its built-in modules. If not found it looks through the list of directories(a directory is a folder that contains related modules) defined by sys.path.
There are three ways to specify a path :
DEFAULT- By default, the interpreter looks for a module within the current directory. To make the interpreter search in some other directory you just simply have to change the current directory. The following example depicts a default path taken by the interpreter:
Python3
# importing moduleimport sys  # printing all directories for # interpreter to searchsys.path
Output:
THROUGH ENVIRONMENT VARIABLES- An environment variable that contains the path an interpreter can take while looking for modules can be employed. Once set, it hints interpreter with directories to locate a module.  The following example shows how this can be done.
PYTHONPATH=C:\Users\Vanshi\Desktop

Python3
# importing moduleimport sys  # printing all directoriessys.path
Output:
APPENDING PATH- append() is a built-in function of sys module that can be used with path variable to add a specific path for interpreter to search. The following example shows how this can be done.
Python3
# importing moduleimport sys  # appending a pathsys.path.append('C:/Users/Vanshi/Desktop')  # printing all pathssys.path
Output:
Note that the first string returned by path is always empty this is to indicate the interpreter to check in the current directory.
Python-sys
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.pyplot.colors() in Python

03 May, 2020
In Python we can plot graphs for visualization using Matplotlib library. For integrating plots into applications, Matplotlib provides an API. Matplotlib has a module named pyplot which provides a MATLAB-like interface.
This function is used to specify the color. It is do-nothing function.
We can use this function for various data visualizations and obtain insights from them.
Examples 1:
import matplotlib.pyplot as plt    # Define the Colorcolor = 'green'plt.plot([1, 2, 3, 4], color = color)  plt.show()
Output:
Example 2:
import matplotlib.pyplot as plt    x = [1, 2, 3, 4]y= [1, 4, 9, 16]  plt.plot(x, y, marker = 'o', markerfacecolor = 'r')  plt.show()
Output:
Here, marker=’o’ represents circle while markerfacecolor is used for specifying color of the point marker.
Note: This function has been deprecated since version 2.1.
Matplotlib Pyplot-class
Python-matplotlib
Python
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between wait and sleep in Java

16 Jun, 2021
Sleep(): This Method is used to pause the execution of current thread for a specified time in Milliseconds. Here, Thread does not lose its ownership of the monitor and resume’s it’s execution
Wait(): This method is defined in object class. It tells the calling thread (a.k.a Current Thread) to wait until another thread invoke’s the notify() or notifyAll() method for this object, The thread waits until it reobtains the ownership of the monitor and Resume’s Execution.
Wait() Has Three Overloaded Methods:
wait()
wait(long timeout)
wait(long timeout, int nanos)
Sleep() Has Two Overloaded Methods:
sleep(long millis)millis: milliseconds
sleep(long millis,int nanos) nanos: Nanoseconds
Example For Sleep Method:
synchronized(monitor)
{
Thread.sleep(1000);  Here Lock Is Held By The Current Thread
//after 1000 milliseconds, current thread will wake up, or after we call that is interrupt() method
}
Example For wait Method:
synchronized(monitor)
{
monitor.wait()  Here Lock Is Released By Current Thread 
}
Similarity Between Both wait() and sleep() Method: 
Both Make The Current Thread go Into the Not Runnable State.Both are Native Methods.
Both Make The Current Thread go Into the Not Runnable State.
Both are Native Methods.
The Below Code Snippet For Calling wait() and sleep() Method:
Java
synchronized(monitor){    while(condition == true)    {        monitor.wait()  //releases monitor lock    }     Thread.sleep(100); //puts current thread on Sleep   }
Program:
Java
// Java program to demonstrate the difference// between wait and sleep class GfG{   private static Object LOCK = new Object(); public static void main(String[] args)  throws InterruptedException {      Thread.sleep(1000);       System.out.println("Thread '" + Thread.currentThread().getName() +      "' is woken after sleeping for 1 second");      synchronized (LOCK)    {        LOCK.wait(1000);               System.out.println("Object '" + LOCK + "' is woken after" +          " waiting for 1 second");    }}}
  
Thread 'main' is woken after sleeping for 1 second
Object 'java.lang.Object@1d81eb93' is woken after waiting for 1 second
 
scraptrashscrap
arorakashish0911
Java-Multithreading
Picked
Difference Between
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove shadow of an element in Bootstrap 4

Use the .shadow-none class in Bootstrap to remove shadow.
You can try to run the following code to remove an element’s shadow −
Live Demo
<!DOCTYPE html>
<html lang = "en">
   <head>
      <title>Bootstrap Example</title>
      <meta charset = "utf-8">
      <meta name = "viewport" content="width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container">
         <h1>Learning</h1>
         <p>Learn Tutorials for free</p>
         <div class = "shadow-none p-4 mb-4 bg-light">Play Quiz and check your knowledge</div>
      </div>
   </body>
</html>
Create temporary file in specified directory in Java

A temporary file in the specified directory can be created using the method java.io.File.createTempFile(). This method requires three parameters i.e. the prefix to define the file name, the suffix to define the file extension and the directory in which the temporary file is to be created. It also returns the abstract path name for the temporary file created.
A program that demonstrates this is given as follows −
import java.io.File;
public class Demo {  
   public static void main(String[] args) throws Exception {
      File directory = new File("C:/JavaProgram");
      File file = File.createTempFile("temp", ".java", directory);
      System.out.println(file.getAbsolutePath());
      file.deleteOnExit();
   }
}
The output of the above program is as follows −
C:\JavaProgram\temp1333744144499445058.java
Now let us understand the above program.
A temporary file in the specified directory is created using the method java.io.File.createTempFile(). Then the file path is displayed. Also, the method java.io.File.deleteOnExit() is used to delete the temporary file after the program ends. A code snippet that demonstrates this is given as follows −
File directory = new File("C:/JavaProgram");
File file = File.createTempFile("temp", ".java", directory);
System.out.println(file.getAbsolutePath());
file.deleteOnExit();
Get PID of Browser launched by Selenium.

We can PID of browsers launched by Selenium webdriver. First of all, we have to create an object of the webdriver. Next, for example, to launch the browser in the Firefox browser, we have to take the help of webdriver.Firefox() class.
The location of the geckodriver.exe file is passed as a parameter to that class. This is done by setting the path to executable_path property. Then, the browser shall be launched with the get method.
Finally, to obtain the PID of the browser, we shall use the driver.service.process.id method.
s = driver.service.process.pid
from selenium import webdriver
#path of geckodriver.exe
driver = webdriver.Firefox(executable_path="C:\\geckodriver.exe")
#launch browser
driver.get ("https://www.tutorialspoint.com/index.htm")
#obtain PID of browser
s = driver.service.process.pid
print(s)
#close browser
driver.close()
C/C++ Program for Median of two sorted arrays of same size?

Here we will see how to get the median of two sorted array of the same size. We will use C++ STL to store array elements. After getting two arrays, we will merge them into one. As two arrays of same size are merged, then the final array will always hold even number of elements. We need to take two middle elements, then get the average of them for the median.
Begin
   arr3 := array after merging arr1 and arr2
   sort arr3
   len := length of arr3
   mid := len/2
   median := (arr3[mid] + arr3[mid-1])/2
   return median
End
 Live Demo
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
float median(vector<int> arr1, vector<int> arr2) {
   vector arr3(arr1.size() + arr2.size());
   merge(arr1.begin(), arr1.end(), arr2.begin(), arr2.end(), arr3.begin());
   sort(arr3.begin(), arr3.end());
   int len = arr3.size();
   int mid = len/2;
   return float(arr3[mid] + arr3[mid-1])/2;
}
main() {
   vector<int> arr1 = {1, 3, 4, 6, 7};
   vector<int> arr2 = {4, 5, 7, 8, 9};
   cout << "Median: " << median(arr1, arr2);
}
Median: 5.5
Number.longValue() method in java with examples - GeeksforGeeks

20 Jun, 2018
The java.lang.Number.longValue() is an inbuilt method in java that returns the value of the specified number casted to long data type. This may involve rounding or truncation.
Syntax:
public abstract long longValue()

Parameters: This method does not accepts any parameter.
Return value: This method returns the numeric value represented by this object after conversion to type long.
Below program illustrate the Number.longValue() method:
Program 1:
// java program to demonstrate// Number.longValue() methodpublic class gfg {      public static void main(String[] args)    {          // number as float        Float x = new Float(127483456f);        // print the value as long        System.out.println(x.longValue());          // number as double        Double y = new Double(78549876);        // print the value as long        System.out.println(y.longValue());    }}
127483456
78549876

Program 2:
// java program to demonstrate// Number.longValue() methodpublic class gfg {      public static void main(String[] args)    {          // number as float        Float x = new Float(127f);        // print the value as long        System.out.println(x.longValue());          // number as double        Double y = new Double(76.23);        // print the value as long        System.out.println(y.longValue());    }}
127
76

Java-Functions
Java-lang package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Functional Interfaces in Java
Stream In Java
Constructors in Java
Different ways of Reading a text file in Java
Exceptions in Java
Generics in Java
Comparator Interface in Java with Examples
Strings in Java
Difference between Abstract Class and Interface in Java
How to remove an element from ArrayList in Java?
map operator= in C++ STL - GeeksforGeeks

12 Jul, 2018
The map::operator= is a built function in C++ STL which assigns contents of a container to a different container, replacing its current content.
Syntax:
map1_name = map2_name
Parameters: The map on the left is the container in which the map on the right is to be assigned by destroying the elements of map1.
Return Value: This function does not return anything.
// C++ program for illustration of// map::operator= function#include <bits/stdc++.h>using namespace std;  int main(){      // initialize container    map<int, int> mp, copymp;      // insert elements in random order    mp.insert({ 2, 30 });    mp.insert({ 1, 40 });    mp.insert({ 4, 50 });      // = operator is used to copy map    copymp = mp;      // prints the elements    cout << "\nThe map mp is : \n";    cout << "KEY\tELEMENT\n";    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {        cout << itr->first             << '\t' << itr->second << '\n';    }      cout << "\nThe map copymap is : \n";    cout << "KEY\tELEMENT\n";    for (auto itr = copymp.begin(); itr != copymp.end(); ++itr) {        cout << itr->first             << '\t' << itr->second << '\n';    }    return 0;}
The map mp is : 
KEY    ELEMENT
1    40
2    30
4    50

The map copymap is : 
KEY    ELEMENT
1    40
2    30
4    50

CPP-Functions
cpp-map
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Inheritance in C++
Constructors in C++
C++ Classes and Objects
Bitwise Operators in C/C++
Socket Programming in C/C++
Operator Overloading in C++
Multidimensional Arrays in C / C++
Copy Constructor in C++
Virtual Function in C++
Templates in C++ with Examples
How to Create a Multi-line Text Input (Text Area) In HTML?

To create a multi-line text input, use the HTML <textarea> tag. You can set the size of a text area using the cols and rows attributes. It is used within a form, to allow users to input text over multiple rows.
Here are the attributes of <textarea> tag −
You can try to run the following code to create a multi-line text input in HTML −
<!DOCTYPE html>
<html>
   <head>
      <title>HTML textarea Tag</title>
   </head>

   <body>
      <form action = "/cgi-bin/hello_get.cgi" method = "get">
         What improvements you want in College?
         <br>
         <textarea rows = "5" cols = "60" name = "description">
            Enter details here...
         </textarea><br>
         <input type = "submit" value = "submit" />
      </form>
   </body>
</html>
Objective-C Overview

Objective-C is general-purpose language that is developed on top of C Programming language by adding features of Small Talk programming language making it an object-oriented language. It is primarily used in developing iOS and Mac OS X operating systems as well as its applications.
Initially, Objective-C was developed by NeXT for its NeXTSTEP OS from whom it was taken over by Apple for its iOS and Mac OS X.
Objective-C fully supports object-oriented programming, including the four pillars of object-oriented development −
Encapsulation
Data hiding
Inheritance
Polymorphism
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

   NSLog (@"hello world");
   [pool drain];
   return 0;
}
Foundation Framework provides large set of features and they are listed below.
It includes a list of extended datatypes like NSArray, NSDictionary, NSSet and so on.
It includes a list of extended datatypes like NSArray, NSDictionary, NSSet and so on.
It consists of a rich set of functions manipulating files, strings, etc.
It consists of a rich set of functions manipulating files, strings, etc.
It provides features for URL handling, utilities like date formatting, data handling, error handling, etc.
It provides features for URL handling, utilities like date formatting, data handling, error handling, etc.
The most important thing to do when learning Objective-C is to focus on concepts and not get lost in language technical details.
The purpose of learning a programming language is to become a better programmer; that is, to become more effective at designing and implementing new systems and at maintaining old ones.
Objective-C, as mentioned earlier, is used in iOS and Mac OS X. It has large base of iOS users and largely increasing Mac OS X users. And since Apple focuses on quality first and its wonderful for those who started learning Objective-C.

    18 Lectures 
     1 hours 

 PARTHA MAJUMDAR

    6 Lectures 
     25 mins

 Ken Burke
 Print
 Add Notes
 Bookmark this page
React ES6 Destructuring

To illustrate destructuring, we'll make a sandwich. Do you take everything out of the refrigerator to make your sandwich? No, you only take out the items you would like to use on your sandwich.
Destructuring is exactly the same. We may have an array or object that we are working with, but we only need some of the items contained in these.
Destructuring makes it easy to extract only what is needed.
Here is the old way of assigning array items to a variable:
const vehicles = ['mustang', 'f-150', 'expedition'];

// old way
const car = vehicles[0];
const truck = vehicles[1];
const suv = vehicles[2];
Here is the new way of assigning array items to a variable:
const vehicles = ['mustang', 'f-150', 'expedition'];

const [car, truck, suv] = vehicles;
When destructuring arrays, the order that variables are declared is important.
If we only want the car and suv we can simply leave out the truck but keep the comma:
const vehicles = ['mustang', 'f-150', 'expedition'];

const [car,, suv] = vehicles;
Destructuring comes in handy when a function returns an array:
function calculate(a, b) {
  const add = a + b;
  const subtract = a - b;
  const multiply = a * b;
  const divide = a / b;

  return [add, subtract, multiply, divide];
}

const [add, subtract, multiply, divide] = calculate(4, 7);

Try it Yourself »

Here is the old way of using an object inside a function:
const vehicleOne = {
  brand: 'Ford',
  model: 'Mustang',
  type: 'car',
  year: 2021, 
  color: 'red'
}

myVehicle(vehicleOne);

// old way
function myVehicle(vehicle) {
  const message = 'My ' + vehicle.type + ' is a ' + vehicle.color + ' ' + vehicle.brand + ' ' + vehicle.model + '.';
}
Here is the new way of using an object inside a function:
const vehicleOne = {
  brand: 'Ford',
  model: 'Mustang',
  type: 'car',
  year: 2021, 
  color: 'red'
}

myVehicle(vehicleOne);

function myVehicle({type, color, brand, model}) {
  const message = 'My ' + type + ' is a ' + color + ' ' + brand + ' ' + model + '.';
}

Try it Yourself »

Notice that the object properties do not have to be declared in a specific order.
We can even destructure deeply nested objects by referencing the nested object then using a colon and curly braces to again destructure the items needed from the nested object:
const vehicleOne = {
  brand: 'Ford',
  model: 'Mustang',
  type: 'car',
  year: 2021, 
  color: 'red',
  registration: {
    city: 'Houston',
    state: 'Texas',
    country: 'USA'
  }
}

myVehicle(vehicleOne)

function myVehicle({ model, registration: { state } }) {
  const message = 'My ' + model + ' is registered in ' + state + '.';
}

Try it Yourself »

Use destructuring to extract only the third item from the array, into a variable named suv.
const vehicles = ['mustang', 'f-150', 'expedition'];

const [] = vehicles;

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
GATE | GATE-CS-2016 (Set 2) | Question 47 - GeeksforGeeks

12 Aug, 2021
Consider the following program:
int f(int *p, int n){    if (n <= 1) return 0;    else return max(f(p+1,n-1),p[0]-p[1]);}int main(){    int a[] = {3,5,2,6,4};    printf("%d", f(a,5));}
Note: max(x,y) returns the maximum of x and y. The value printed by this program is
(A) 2(B) 3(C) 4(D) 5Answer: (B)Explanation: Look at the recursion stack of the given code in the below image. Assuming that the base address of array starts from 1000 and an integer takes 4 Bytes.
After the last recursive call f(1016,1) returns, in the previous call we will have return max(0,2) and then return max(2,-4) and then return max(2,3) and then finally return max(3,-2) = 3.
This solution is contributed by Pranjul Ahuja
YouTubeGeeksforGeeks GATE Computer Science16.1K subscribersGATE PYQs 2016 with Shubham Agrawal | GeeksforGeeks GATE CSEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.More videosMore videosYou're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:001:00:08 / 1:07:54•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=Key2RKhzRGY" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2016 (Set 2)
GATE-GATE-CS-2016 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-1) | Question 30
GATE | GATE-CS-2001 | Question 23
GATE | GATE-CS-2015 (Set 1) | Question 65
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2014-(Set-1) | Question 65
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE CS 2012 | Question 40
C++ Program to count Vowels in a string using Pointer
Scala Map toList() method with example - GeeksforGeeks

26 Jul, 2019
The toList() method is utilized to display the elements of the map in the list.
Method Definition: def toList: List[A]
Return Type: It returns all the elements of the map in the list.
Example #1:
// Scala program of toList()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Creating a map        val m1 = Map(3 -> "geeks", 4 -> "for", 2 -> "cs")                  // Applying toList method        val result = m1.toList                  // Displays output        println(result)          }}
List((3, geeks), (4, for), (2, cs))

Example #2:
// Scala program of toList()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Creating a map        val m1 = Map(3 -> "geeks", 4 -> "for", 4 -> "for")                  // Applying toList method        val result = m1.toList                  // Displays output        println(result)          }}
List((3, geeks), (4, for))

Scala
Scala-Map
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scala Lists
Class and Object in Scala
Scala Constructors
Scala Tutorial – Learn Scala with Step By Step Guide
Operators in Scala
Scala | Arrays
How to get the first element of List in Scala
Scala Map get() method with example
Scala String substring() method with example
Lambda Expression in Scala
C++ Program to Check Whether a Hamiltonian Cycle or Path Exists in a Given Graph

A Hamiltonian cycle is a Hamiltonian Path such that there is an edge (in graph) from the last vertex to the first vertex of the Hamiltonian Path. It is in an undirected graph is a path that visits each vertex of the graph exactly once.
Begin
   1.function isSafe() is used to check for whether it is adjacent to the previously added vertex and already not added.
   2. function hamiltonianCycle() solves the hamiltonian problem.
   3. function hamCycle() uses hamiltonianCycle() to solve the hamiltonian problem.
      It returns false if there is no Hamiltonian Cycle possible, otherwise return true and prints the path.
End
#include <iostream>
#include <cstdio>
#include <cstdlib>
#define N 5
using namespace std;
void displaytheSolution(int path[]);
bool isSafe(int n, bool g[N][N], int path[], int pos) {
   if (g [path[pos-1]][n] == 0)
      return false;
   for (int i = 0; i < pos; i++)
      if (path[i] == n)
         return false;
   return true;
}
bool hamiltonianCycle(bool g[N][N], int path[], int pos) {
   //If all vertices are included in Hamiltonian Cycle
   if (pos == N) {
      if (g[ path[pos-1] ][ path[0] ] == 1)
         return true;
      else
         return false;
   }
   for (int n = 1; n < N; n++) {
      if (isSafe(n, g, path, pos)) //Check if this vertex can be added to Hamiltonian Cycle
    {
         path[pos] = n;
         //recur to construct rest of the path
         if (hamiltonianCycle (g, path, pos+1) == true)
            return true;
         path[pos] = -1; //remove vertex if it doesn’t lead to the solution
      }
   }
   return false;
}
bool hamCycle(bool g[N][N]) {
   int *path = new int[N];
   for (int i = 0; i < N; i++)
      path[i] = -1;
   //put vertex 0 as the first vertex in the path.
      If there is a Hamiltonian Cycle, then the path can be started from any point
   //of the cycle as the graph is undirected
   path[0] = 0;
   if (hamiltonianCycle(g, path, 1) == false) {
      cout<<"\nCycle does not exist"<<endl;
      return false;
   }
   displaytheSolution(path);
   return true;
}
void displaytheSolution(int p[]) {
   cout<<"Cycle Exists:";
   cout<<" Following is one Hamiltonian Cycle \n"<<endl;
   for (int i = 0; i < N; i++)
      cout<<p[i]<<" ";
      cout<< p[0]<<endl;
}
int main() {
   bool g[N][N] = {
      {0, 1, 0, 1, 1},
      {0, 0, 1, 1, 0},
      {0, 1, 0, 1, 1},
      {1, 1, 1, 0, 1},
      {0, 1, 1, 0, 0},
   };
   hamCycle(g);
   return 0;
}
Cycle Exists: Following is one Hamiltonian Cycle
0 4 1 2 3 0