code-rag-bench/online-tutorials huggingface dataset:
Destructors in C++ - GeeksforGeeks

09 Sep, 2021
What is a destructor? Destructor is an instance member function which is invoked automatically whenever an object is going to be destroyed. Meaning, a destructor is the last function that is going to be called before an object is destroyed.
The thing is to be noted here, if the object is created by using new or the constructor uses new to allocate memory which resides in the heap memory or the free store, the destructor should use delete to free the memory.   
Syntax:
~constructor-name();
Properties of Destructor:
Destructor function is automatically invoked when the objects are destroyed.
It cannot be declared static or const.
The destructor does not have arguments.
It has no return type not even void.
An object of a class with a Destructor cannot become a member of the union.
A destructor should be declared in the public section of the class.
The programmer cannot access the address of destructor.
When is destructor called? A destructor function is called automatically when the object goes out of scope: (1) the function ends (2) the program ends (3) a block containing local variables ends (4) a delete operator is called  
How are destructors different from a normal member function? Destructors have same name as the class preceded by a tilde (~) Destructors don’t take any argument and don’t return anything
CPP
class String {private:    char* s;    int size; public:    String(char*); // constructor    ~String(); // destructor}; String::String(char* c){    size = strlen(c);    s = new char[size + 1];    strcpy(s, c);}String::~String() { delete[] s; }
Can there be more than one destructor in a class? No, there can only one destructor in a class with classname preceded by ~, no parameters and no return type.
When do we need to write a user-defined destructor? If we do not write our own destructor in class, compiler creates a default destructor for us. The default destructor works fine unless we have dynamically allocated memory or pointer in class. When a class contains a pointer to memory allocated in class, we should write a destructor to release memory before the class instance is destroyed. This must be done to avoid memory leak.
Can a destructor be virtual? Yes, In fact, it is always a good idea to make destructors virtual in base class when we have a virtual function. See virtual destructor for more details. You may like to take a quiz on destructors.
Related Articles : Constructors in C++ Virtual Destructor Pure virtual destructor in C++Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
itskawal2000
pushapbadyal07
divyanshubargali
user_ax8z
cpp-destructor
C++
School Programming
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
std::sort() in C++ STL
Bitwise Operators in C/C++
Socket Programming in C/C++
Python Dictionary
Reverse a string in Java
Interfaces in Java
Overriding in Java
Different ways of Reading a text file in Java
How many ways to call garbage collector (GC) in Java?


The garbage collection in Java is carried by a daemon thread called Garbage Collector(GC). Instead of waiting until JVM to run a garbage collector we can request JVM to run the garbage collector. There is no guarantee whether the JVM will accept our request or not.
In Java, we can call the garbage collector manually in two ways
By using System class
By using Runtime class
System class has a static method gc(), which is used to request JVM to call garbage collector.
public class SystemClassTest {
   public static void main(String[] args){
      SystemClassTest test = new SystemClassTest();
      test = null;
      System.gc();
   }
   public void finalize() {
      System.out.println("Garbage collected");
   }
}
Garbage collected
Runtime is a singleton class in Java and we can get a runtime object using the getRuntime() method. The gc() method is from Runtime class and it is an instance method.
public class RuntimeClassTest {
   public static void main(String[] args) {
      RuntimeClassTest test = new RuntimeClassTest();
      test = null;
      Runtime.getRuntime().gc();
   }
   public void finalize() {
      System.out.println("Garbage Collected");
   }
}
Garbage collected
Matrix Chain Multiplication (A O(N^3) Solution) in C++

If a chain of matrices is given, we have to find minimum number of correct sequence of matrices to multiply.
We know that the matrix multiplication is associative, so four matrices ABCD, we can multiply A(BCD), (AB)(CD), (ABC)D, A(BC)D, in these sequences. Like these sequences, our task is to find which ordering is efficient to multiply.
In the given input there is an array say arr, which contains arr[] = {1, 2, 3, 4}. It means the matrices are of the order (1 x 2), (2 x 3), (3 x 4).
Input − The orders of the input matrices. {1, 2, 3, 4}. It means the matrices are
{(1 x 2), (2 x 3), (3 x 4)}.
Output − Minimum number of operations need multiply these three matrices. Here the result is 18.
matOrder(array, n)
Input: List of matrices, the number of matrices in the list.
Output: Minimum number of matrix multiplication.
Begin
   define table minMul of size n x n, initially fill with all 0s
   for length := 2 to n, do
      for i:=1 to n-length, do
         j := i + length – 1
         minMul[i, j] := ∞
         for k := i to j-1, do
            q := minMul[i, k] + minMul[k+1, j] + array[i-1]*array[k]*array[j]
            if q < minMul[i, j], then
               minMul[i, j] := q
            done
         done
      done
   return minMul[1, n-1]
End
#include<iostream>
using namespace std;
int matOrder(int array[], int n){
   int minMul[n][n]; //holds the number of scalar multiplication needed
   for (int i=1; i<n; i++)
      minMul[i][i] = 0; //for multiplication with 1 matrix, cost is 0
      for (int length=2; length<n; length++){ //find the chain length starting from 2
         for (int i=1; i<n-length+1; i++){
            int j = i+length-1;
            minMul[i][j] = INT_MAX; //set to infinity
            for (int k=i; k<=j-1; k++){
               //store cost per multiplications
               int q = minMul[i][k] + minMul[k+1][j] + array[i-1]*array[k]*array[j];
               if (q < minMul[i][j])
                  minMul[i][j] = q;
            }
      }
   }
   return minMul[1][n-1];
}
int main(){
   int arr[] = {1, 2, 3, 4};
   int size = 4;
   cout << "Minimum number of matrix multiplications: "<<matOrder(arr, size);
}
Minimum number of matrix multiplications: 18
Tryit Editor v3.7

CSS Grid Item
Tryit: A five items grid layout
C Program to check the type of character entered

Write a program to find out that a given character is upper case, lower case, number or special character.
If an entered character is capital letter then, it displays the upper case.
Example: Input =H
Output: upper case letter
If an entered character is small letter then, it displays the lower case letter.
Example: Input= g
Output: lower case letter
If an entered character is number then, it displays the digit.
Example: Input=3
Output: digit
If an entered character is a special character then, it displays the special character.
Example: Input= &
Output: special character
Refer an algorithm given below to find out that a given character is upper case, lower case, number or special character.
Step 1 − Read input character from console at runtime.
Step 2 − Compute ASCII value of the character.
Step 3 − If the ASCII value of the character is in the range of 65 and 90, Then, print "Upper Case letter".
Step 4 − If the ASCII value of the character is in the range of 97 and 122, Then, print "Lower Case letter".
Step 5 − If the ASCII value of the character is in the range of 48 and 57, Then, print "Number".
Step 6 − Else, print "Symbol".
Following is the C program to find out that a given character is upper case, lower case, number or special character −
 Live Demo
#include<stdio.h>
int main(){
   char ch;
   printf("enter a character:");
   scanf("%c",&ch);
   if(ch >= 65 && ch <= 90)
      printf("Upper Case Letter");
   else if(ch >= 97 && ch <= 122)
      printf("Lower Case letter");
   else if(ch >= 48 && ch <= 57)
      printf("Number");
   else
      printf("Symbol");
   return 0;
}
When the above program is executed, it produces the following output −
Run 1:
enter a single character:45
Number
Run 2:
enter a character:#
Symbol
Run 3:
enter a character:M
Upper Case Letter
How to get days, months and years between two Java LocalDate?

Set the two Java dates:
LocalDate date1 = LocalDate.of(2019, 3, 25);
LocalDate date2 = LocalDate.of(2019, 4, 29);
Now, get the difference between two dates with Period class between() method:
Period p = Period.between(date1, date2);
Now, get the years, month and days:
p.getYears()
p.getMonths()
p.getDays()
import java.time.LocalDate;
import java.time.Period;
public class Demo {
   public static void main(String[] args) {
      LocalDate date1 = LocalDate.of(2019, 3, 25);
      LocalDate date2 = LocalDate.of(2019, 4, 29);
      System.out.println("Date 1 = "+date1);
      System.out.println("Date 2 = "+date2);
      Period p = Period.between(date1, date2);
      System.out.println("Period = "+p);
      System.out.println("Years (Difference) = "+p.getYears());
      System.out.println("Month (Difference) = "+p.getMonths());
      System.out.println("Days (Difference) = "+p.getDays());
   }
}
Date 1 = 2019-03-25
Date 2 = 2019-04-29
Period = P1M4D
Years (Difference) = 0
Month (Difference) = 1
Days (Difference) = 4
Deleting records in MySQL using Nodejs

After insertion, we need to delete records as well. The records should can be deleted based upon an identifier from the database table. You can delete records from table using "DELETE FROM" statement.
We can delete the records from MySql DB in two ways −
Static Deletion - In this type of deletion, we give a prefixed filter value to delete
Static Deletion - In this type of deletion, we give a prefixed filter value to delete
Dynamic Deletion – In this type of deletion, we ask for an input before deletion and then delete upon its basis.
Dynamic Deletion – In this type of deletion, we ask for an input before deletion and then delete upon its basis.
Before proceeding, please check the following steps are already executed −
mkdir mysql-test
mkdir mysql-test
cd mysql-test
cd mysql-test
npm init -y
npm init -y
npm install mysql
npm install mysql
The above steps are for installing the Node - mysql dependecy in the project folder.
Following are the examples on how to delete records from MySql using Nodejs.
For deleting records from the MySQL table, create an app.js file.
For deleting records from the MySQL table, create an app.js file.
Now copy-paste the below snippet in the file
Now copy-paste the below snippet in the file
Run the code using the following command
Run the code using the following command
   >> node app.js
var mysql = require('mysql');
var con = mysql.createConnection({
   host: "localhost",
   user: "yourusername",
   password: "yourpassword",
   database: "mydb"
});

con.connect(function(err) {
   if (err) throw err;

   //Delete the records with address="Delhi"
   var sql = "DELETE FROM student WHERE address = 'Delhi'; "
   con.query(sql, function (err, result) {
      if (err) throw err;
      console.log("Record deleted = ", results.affectedRows);
      console.log(result);
   });
});
Record deleted = 1
OkPacket {
   fieldCount: 0,
   affectedRows: 1, // No of Records Deleted
   insertId: 0,
   serverStatus: 34,
   warningCount: 0,
   message: '',
   protocol41: true,
   changedRows: 0
}
The following example will take address field as the input and only delete the records which match the filter.
var mysql = require('mysql');
var con = mysql.createConnection({
   host: "localhost",
   user: "yourusername",
   password: "yourpassword",
   database: "mydb"
});

con.connect(function(err) {
   if (err) throw err;

// Delete the desired record from table
let sql = `DELETE FROM student WHERE address = ?`;
// delete a row with address=Delhi
   con.query(sql, 'Dehi', (err, result, fields) => {
      if (err) throw err;
      console.log("Record deleted = ", results.affectedRows);
      console.log(result);
   });
});
OkPacket {
   fieldCount: 0,
   affectedRows: 3, // 3 Rows deleted for address=Delhi
   insertId: 0,
   serverStatus: 34,
   warningCount: 0,
   message: '',
   protocol41: true,
   changedRows: 0
}
XSLT <key>

<xsl:key> tag element specifies a named name-value pair assigned to a specific element in an XML document. This key is used with the key() function in XPath expressions to access the assigned elements in an XML document.
Following is the syntax declaration of <xsl:key> element.
<xsl:key 
   name = QName 
   match = Pattern 
   use = Expression > 
</xsl:key>

Name
Name of the key to be used.
Match
Patterns used to identify a node that holds this key.
Use
XPath expression to identify the value of the nodes of xml document.
This example creates a table of <student> element with its attribute rollno and its child <firstname>, <lastname>, <nickname>, and <marks> by iterating over each student. It checks key as firstname to be one of the student's name and then prints the student details.
students.xml
<?xml version = "1.0"?> 
<?xml-stylesheet type = "text/xsl" href = "students.xsl"?> 
<class> 
   <student rollno = "393"> 
      <firstname>Dinkar</firstname> 
      <lastname>Kad</lastname> 
      <nickname>Dinkar</nickname> 
      <marks>85</marks> 
   </student> 
   <student rollno = "493"> 
      <firstname>Vaneet</firstname> 
      <lastname>Gupta</lastname> 
      <nickname>Vinni</nickname> 
      <marks>95</marks> 
   </student> 
   <student rollno = "593"> 
      <firstname>Jasvir</firstname> 
      <lastname>Singh</lastname> 
      <nickname>Jazz</nickname> 
      <marks>90</marks> 
   </student> 
</class>
students.xsl
<xsl:stylesheet version = "1.0" 
   xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
   <xsl:key name = "firstname-search" match = "student" use = "firstname"/> 
   <xsl:template match = "/"> 
      <html> 
         <body> 
            <h2>Students</h2> 
            <table border = "1"> 
               <tr bgcolor = "#9acd32"> 
                  <th>Roll No</th> 
                  <th>First Name</th> 
                  <th>Last Name</th> 
                  <th>Nick Name</th> 
                  <th>Marks</th> 
               </tr> 
					
               <xsl:for-each select = "key('firstname-search', 'Dinkar')"> 
				
                  <tr> 
                     <td><xsl:value-of select = "@rollno"/></td> 
                     <td><xsl:value-of select = "firstname"/></td> 
                     <td><xsl:value-of select = "lastname"/></td> 
                     <td><xsl:value-of select = "nickname"/></td> 
                     <td><xsl:value-of select = "marks"/></td> 
                  </tr> 
					
               </xsl:for-each> 
            </table> 
         </body> 
      </html> 
   </xsl:template>  
</xsl:stylesheet>
 Print
 Add Notes
 Bookmark this page
What is the Java equivalent to MySQL's smallint?

The short is equivalent to MySQL’s small int. The Java short takes 2 bytes that has the range -32768 to 32767 while MySQL smallint also take 2 bytes with same range.
Here is the demo code of short in Java −
public class SmallIntAsShortDemo {
   public static void main(String[] args) {
      short value = 32767;
      System.out.println(value);
      value = -32768;
      System.out.println(value);
      // value = 32768;
      // System.out.println(value);
   }
}
The snapshot is as follows −
This will produce the following output −
32767
-32768
Here is the snapshot of the output we ran in EclipseIDE −
The MySQL smallint takes 2 bytes with same range.
How can I convert a Python Named tuple to a dictionary?

Namedtuple class is defined in the collections module. It returns a new tuple subclass. The new subclass is used to create tuple-like objects that have fields accessible by attribute lookup as well as being indexable and iterable. The constructor takes type name and field list as arguments. For example, a student namedtuple is declared as follows −
>>> from collections import namedtuple
>>> student=namedtuple("student","name, age, marks")
The object of this namedtuple class is declared as −
>>> s1=student("Raam",21,45)
This class has _asdict() method which returns orderdict() object
>>> d=s1._asdict()
>>> d
OrderedDict([('name', 'Raam'), ('age', 21), ('marks', 45)])
To obtain regular dictionary object use dict() function
>>> dct=dict(d)
>>> dct
{'name': 'Raam', 'age': 21, 'marks': 45}
Good
How to clear Text widget content while clicking on the Entry widget itself in Tkinter?

Tkinter Text widget is an Input widget that supports multiline user input. It is also known as Text Editor which allows users to write the content and data in it. The content of the text widget can be cleared by defining the delete(0, END) command. Similarly, we can clear the content by clicking the Entry widget itself. This can be achieved by binding the function with a click event.
#Import the required libraries
from tkinter import *

#Create an instance of Tkinter Frame
win = Tk()

#Set the geometry of Tkinter Frame
win.geometry("700x250")

#Define a function to clear the content of the text widget
def click(event):
   name.configure(state=NORMAL)
   name.delete(0, END)
   name.unbind('<Button-1>', clicked)

#Create a Label widget
label = Label(win, text= "Enter Your Name", font= ('Helvetica 13 bold'))
label.pack(pady= 10)

#Create an Entry widget
name = Entry(win, width=45)
name.insert(0, 'Enter Your Name Here...')
name.pack(pady=10)

#Bind the Entry widget with Mouse Button to clear the content
clicked = name.bind('<Button-1>', click)
win.mainloop()
Running the above code will display a window with an Entry widget.
When we click the Entry field, it will clear its content automatically.
Sum of XOR of sum of all pairs in an array in C++

In this problem, we are given an array arr[] of size n. Our task is to create a program to find the sum of XOR of sum of all pairs in an array.
Let’s see an example to understand the problem, 
Input: arr[5, 7, 9]
Output: 22
Explanation: 
(5+5) ^ (5+7) ^ (5+9) ^ (7+5) ^ (7+7) ^ (7+9) ^ (9+5) ^ (9+7) ^ (9+9) = 22
A simple solution to the problem is by using a nested loop. And creating all possible pairs from the array. And calculate the XOR of the sum of each pair.
Algorithm: 
Initialise XorSum = 0
Step 1: iterate from 0 to n. Follow:
Step 1.1: iterate from 0 to n. Follow
Step 1.1.1: Update XorSum i.e. XorSum = XorSum ^ (arr[i]+arr[j]).
Step 2: return sum
Live Demo
#include <iostream>
using namespace std;

int findSumXORPair(int arr[], int n) {

   int XorSum = 0;
   for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
       XorSum = XorSum^(arr[i]+arr[j]);
   return XorSum;
}

int main() {

   int arr[] = {5, 7, 9};
   int n = sizeof(arr)/sizeof(arr[0]);
   cout<<"XOR of sum of all pairs in an array is "<<findSumXORPair(arr, n);
   return 0;
}
XOR of sum of all pairs in an array is 22
This solution is not efficient as its time complexity is of the order n2.
An efficient solution is using the properties of XOR. To solve the problem, we will calculate the XOR of all elements of the array and then multiply it by two.
Algorithm: 
Initialize XorSum = 0
Step 1: Iterate from 0 to n.
Step 1.1: update XorSum i.e. XorSum = XorSum ^ arr[i]
Step 2: double the sum and return it.
Live Demo
#include <iostream>
using namespace std;

int findSumXORPair(int arr[], int n) {

   int XorSum = 0;
   for (int i = 0; i < n; i++)
    XorSum = XorSum^arr[i];
   XorSum = 2*XorSum;
   return XorSum;
}

int main() {

int arr[] = {5, 7, 9};
   int n = sizeof(arr)/sizeof(arr[0]);
   cout<<"XOR of sum of all pairs in an array is "<<findSumXORPair(arr, n);
   return 0;
}
XOR of sum of all pairs in an array is 22
What are the differences between protected and default access specifiers in Java?

The Protected access specifier is visible within the same package and also visible in the subclass whereas the Default is a package level access specifier and it can be visible in the same package.
Protected will acts as public within the same package and acts as private outside the package.
Protected will also act as public outside the package only with respect to subclass objects.
Protected fields or methods cannot be used for classes and Interfaces.
The Fields, methods, and constructors declared as protected in a superclass can be accessed only by subclasses in other packages.
The classes in the same package can also access protected fields, methods and constructors as well, even if they are not a subclass of the protected member’s class.
Live Demo
public class ProtectedTest {
   // variables that are protected
   protected int age = 30;
   protected String name = "Adithya";

   /**
    * This method is declared as protected.
    */
   protected String getInfo() {
      return name +" is "+ age +" years old.";
   }
   public static void main(String[] args) {
      System.out.println(new ProtectedTest().getInfo());
   }
}
Adithya is 30 years old.

Any member of a class mentioned without any access specifier then it is considered that as Default.
The Default will act as public within the same package and acts as private outside the package.
The Default members of any class can be available to anything within the same package and can not be available outside the package under any condition.
The Default restricts the access only to package level, even after extending the class having default data members we cannot able to access.
Live Demo
public class DefaultTest {
   // variables that have no access modifier
   int age = 25;
   String name = "Jai";

   /**
    * This method is declared with default aacees specifier
    */
   String getInfo() {
      return name +" is "+ age +" years old.";
   }
   public static void main(String[] args) {
      System.out.println(new DefaultTest().getInfo());
   }
}
Jai is 25 years old.
Difference between Static and Dynamic Testing - GeeksforGeeks

27 Feb, 2020
Static Testing:Static Testing is a type of a Software Testing method which is performed to check the defects in software without actually executing the code of the software application.
Static testing is performed in early stage of development to avoid errors as it is easier to find sources of failures and it can be fixed easily. The errors that can’t not be found using Dynamic Testing, can be easily found by Static Testing.
Dynamic Testing:Dynamic Testing is a type of Software Testing which is performed to analyze the dynamic behavior of the code. It includes the testing of the software for the input values and output values that are analyzed.
Difference between Static Testing and Dynamic Testing:
Verification
Validation
ashushrma378
Software Testing
Software Engineering
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Functional vs Non Functional Requirements
Software Engineering | Classical Waterfall Model
Software Requirement Specification (SRS) Format
Differences between Verification and Validation
Software Engineering | Requirements Engineering Process
Levels in Data Flow Diagrams (DFD)
Software Engineering | Requirements Elicitation
DFD for Library Management System
Software Engineering | SDLC V-Model
What is DFD(Data Flow Diagram)?
DAX Date & Time - TIMEVALUE function

Converts time in text format to time in datetime format.
TIMEVALUE (<time_text>) 

time_text
A text string that represents a certain time of the day.
Any date information included in the time_text parameter is ignored.
A date in datetime format.
When the time_text parameter is a text representation of the date and time, DAX TIMEVALUE function uses the locale and date/time settings of the client computer to understand the text value in order to perform the conversion. Most locales use the colon (:) as the time separator, and any input text using colons as time separators will parse correctly.
Review your locale settings to understand your results.
= TIMEVALUE ("14:45:35") returns 12/30/1899 2:45:35 PM. 
= TIMEVALUE ("2:35:55") returns 12/30/1899 2:35:55 AM.  

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
Python Functions - GeeksforGeeks

18 Jan, 2021
chr(ord('A'))

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Comments
Old Comments
Must Do Coding Questions for Product Based Companies
How to set background images in ReactJS ?
Microsoft Interview Experience for Internship (Via Engage)
Difference between var, let and const keywords in JavaScript
Array of Objects in C++ with Examples
How to Alter Multiple Columns at Once in SQL Server?
How to Replace Values in Column Based on Condition in Pandas?
How to Fix: SyntaxError: positional argument follows keyword argument in Python
C Program to read contents of Whole File
How to Replace Values in a List in Python?
How to load external website into an <iframe> using jQuery?

To load an external HTML into <iframe> using jQuery, use the attr() method. In that set the source for iframe. You can try to run the following code to learn how to locate external HTML −
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
   $('#iframe').attr('src', 'https://www.qries.com');
});
</script>
</head>
<body>

<iframe id="iframe" name="myIframe" frameborder="5" width="500" height="300"></iframe>

</body>
</html>
Spring MVC - Generate JSON Example

The following example shows how to generate JSON using the Spring Web MVC Framework. To start with, let us have a working Eclipse IDE in place and consider the following steps to develop a Dynamic Form based Web Application using the Spring Web Framework −
package com.tutorialspoint;

public class User {
   private String name;
   private int id;
   public String getName() {
      return name;
   }  
   public void setName(String name) {
      this.name = name;
   }
   public int getId() {
      return id;
   }   
   public void setId(int id) {
      this.id = id;
   }	
}
package com.tutorialspoint;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/user")
public class UserController {
	
   @RequestMapping(value="{name}", method = RequestMethod.GET)
   public @ResponseBody User getUser(@PathVariable String name) {

      User user = new User();

      user.setName(name);
      user.setId(1);
      return user;
   }
}
<beans xmlns = http://www.springframework.org/schema/beans"
   xmlns:context = http://www.springframework.org/schema/context"   
   xmlns:xsi = http://www.w3.org/2001/XMLSchema-instance"
   xmlns:mvc = http://www.springframework.org/schema/mvc"
   xsi:schemaLocation = 
   http://www.springframework.org/schema/beans     
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/context 
   http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
   <context:component-scan base-package = com.tutorialspoint" />
   <mvc:annotation-driven />
</beans>
Here, we have created a Simple POJO User and in UserController we have returned the User. Spring automatically handles the JSON conversion based on RequestMapping and Jackson jar present in the classpath.
Once you are done with creating source and configuration files, export your application. Right click on your application, use Export → WAR File option and save your TestWeb.war file in Tomcat's webapps folder.
Now, start the Tomcat server and make sure you are able to access other webpages from the webapps folder using a standard browser. Try a URL – http://localhost:8080/TestWeb/mahesh and we will see the following screen.
 Print
 Add Notes
 Bookmark this page
How to decorate list bullets in arrow using CSS ? - GeeksforGeeks

22 Apr, 2020
Given a list of items and the task is to customize the bullet style of the list and replace it with the arrow.
Method 1: By Unicode Character
First, we will turn off the default bullet style of the list.
Then We will insert Unicode of the arrow character in the content property in the “li::before” selector.
Example:
<!DOCTYPE html><html>  <head>    <title>Decorating Bullet Style</title>      <!-- Internal css -->    <style type="text/css">                  <!-- Element selected by id -->        #list{            color: green;            background: white;            font-size: 30px;        }          <!-- Removes default style of         bullet point -->        li{            list-style: none;        }          <!-- ::before creates a pseudo-element        that is the first child of the         selected element -->          li::before{              <!-- Unicode for >> character -->            content: "\00BB";        }    </style></head>  <body>      <!-- list of elements -->    <ul id="list">        <li> Geeks</li>        <li> for</li>        <li> Geeks</li>    </ul></body>      </html>
Output:
Method 2:
We will insert URL of the image that we want to insert in place of the default bullet styles in the “list-style-image” property.
Example:
<!DOCTYPE html><html>  <head>    <title>Decorating Bullet Style</title>      <!-- Internal css -->    <style type="text/css">                  <!-- Element selected by id -->        #list{            color: green;            width: 300px;            font-size: 45px;            font-family: sans-serif;            border:2px solid black;        }          ul{            margin: 100px 100px;        }          <!-- Adds desired image at the         in place of default bullets -->        li{            list-style-image:URL('https://media.geeksforgeeks.org/wp-content/uploads/20200331172037/image47.png');            list-style-position: inside;        }    </style></head>  <body>      <!-- list of elements -->    <ul id="list">        <li> Geeks</li>        <li> for</li>        <li> Geeks</li>    </ul></body>      </html>
Output:
References:
https://developer.mozilla.org/en-US/docs/Web/CSS/::before
https://unicode-table.com/en/sets/arrow-symbols/
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
Picked
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to create footer to stay at the bottom of a Web page?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
Design a web page using HTML and CSS
Create a Responsive Navbar using ReactJS
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
Java Examples - Read a file using Applet

How to read a file using Applet?
Following example demonstrates how to read a file using an Applet using openStream() method of URL.
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;

public class readFileApplet extends Applet {
   String fileToRead = "test1.txt";
   StringBuffer strBuff;
   TextArea txtArea;
   Graphics g;
   
   public void init() {
      txtArea = new TextArea(100, 100);
      txtArea.setEditable(false);
      add(txtArea, "center");
      String prHtml = this.getParameter("fileToRead");
      
      if (prHtml != null) fileToRead = new String(prHtml);  
      readFile();
   }
   public void readFile(){
      String line;
      URL url = null;
      try {
         url = new URL(getCodeBase(), fileToRead);
      }
      catch(MalformedURLException e){}
      try {
         InputStream in = url.openStream();
         BufferedReader bf = new BufferedReader(new InputStreamReader(in));
         strBuff = new StringBuffer();
         while((line = bf.readLine()) != null) {
            strBuff.append(line + "\n");
         }
         txtArea.append("File Name : " + fileToRead + "\n");
         txtArea.append(strBuff.toString());
      } catch(IOException e) {
         e.printStackTrace();
      }
   }
}
The above code sample will produce the following result in a java enabled web browser.
View in Browser. 

 Print
 Add Notes
 Bookmark this page
Int16.MaxValue Field in C# with Examples - GeeksforGeeks

08 Apr, 2019
The MaxValue field or property of Int16 Struct is used to represent the maximum value of Int16. The value of this field is constant means that the user cannot change the value of this field. The value of this field is 32767. Its hexadecimal value is 0x7FFF. It is used to avoid the OverflowException while converting from a numeric type with a greater upper range (such as a UInt16 or an Int32) to an Int16.
Syntax:
public const short MaxValue = 32767;
Return Value: This field always returns 32767.
Example:
// C# program to illustrate the// Int16.MaxValue fieldusing System;   class GFG {       // Main Method    static public void Main()    {        // display the Maximum value         // of Int16 struct        Console.WriteLine("Maximum Value is: "+                                Int16.MaxValue);           // Taking an array of long i.e Int64 data type        long[]num = {345, -4677, -65245465445441, 44456564};           // taking variable of Int16 type        short mynum;        foreach(long n in num){               if(n >= Int16.MinValue && n <= Int16.MaxValue)            {                   // using the method of Convert class                // to convert Int64 to Int16                 mynum = Convert.ToInt16(n);                Console.WriteLine("Conversion is Possible.");            }            else            {                Console.WriteLine("Not Possible");            }        }               }}
Output:
Maximum Value is: 32767
Conversion is Possible.
Conversion is Possible.
Not Possible
Not Possible

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.int16.maxvalue?view=netframework-4.7.2
CSharp-Int16-Struct
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Delegates
C# | Method Overriding
C# | Abstract Classes
Difference between Ref and Out keywords in C#
Extension Method in C#
C# | Class and Object
C# | Constructors
C# | Replace() Method
Introduction to .NET Framework
C# | Data Types
PyQt5 – How to stop resizing of window | setFixedSize() method - GeeksforGeeks

26 Mar, 2020
In this article, we will see how to stop resizing of the main window. While making a window, we get options like going full screen and using cursor to change its size. By using setFizedSize() method we can prevent the resizing of the image.
Syntax : self.setFixedSize(width, height)
Argument : It takes two integer as argument i.e width and height.
Action performed : It set the fixed size of window.
Code :
# importing the required libraries  from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * import sys    class Window(QMainWindow):    def __init__(self):        super().__init__()            # set the title        self.setWindowTitle("Python")          width = 500        height = 400        # setting  the fixed size of window        self.setFixedSize(width, height)          # creating a label widget        self.label_1 = QLabel("Fixed size window", self)          # moving position        self.label_1.move(100, 100)          # setting up the border        self.label_1.setStyleSheet("border :3px solid black;")          # resizing label        self.label_1.resize(120, 80)          # show all the widgets        self.show()    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
Convert integer to string in Python
Python | os._exit() method - GeeksforGeeks

10 May, 2022
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. os._exit() method in Python is used to exit the process with specified status without calling cleanup handlers, flushing stdio buffers, etc. Note: This method is normally used in child process after os.fork() system call. The standard way to exit the process is sys.exit(n) method.
Syntax: os._exit(status) 
Parameter: status: An integer value or above defined values representing the exit status. 
Return type: This method does not return any value in the calling process.
Code: Use of os._exit() method 
Python3
# Python program to explain os._exit() method # importing os module import os # Create a child process# using os.fork() methodpid = os.fork()  # pid greater than 0# indicates the parent processif pid > 0:     print("\nIn parent process")    # Wait for the completion    # of child process and       # get its pid and    # exit status indication using    # os.wait() method    info = os.waitpid(pid, 0)          # os.waitpid() method returns a tuple    # first attribute represents child's pid    # while second one represents    # exit status indication     # Get the Exit code    # used by the child process    # in os._exit() method         # firstly check if    # os.WIFEXITED() is True or not    if os.WIFEXITED(info[1]) :        code = os.WEXITSTATUS(info[1])        print("Child's exit code:", code) else :    print("In child process")    print("Process ID:", os.getpid())    print("Hello ! Geeks")    print("Child exiting..")         # Exit with status os.EX_OK    # using os._exit() method    # The value of os.EX_OK is 0           os._exit(os.EX_OK)
In child process
Process ID: 15240
Hello! Geeks
Child exiting..


In parent process
Child's exit code: 0
References: https://docs.python.org/3/library/os.html#os._exit
surinderdawra388
python-os-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
How to convert binary to Hex by using C language?

Binary numbers are represented in 1’s and 0’s.
Hexadecimal number system with 16 digits is {0,1,2,3.....9, A(10), B(11),......F(15)}
To convert from binary to hex representation, the bit string id is grouped in blocks of 4-bits which are called as nibbles from the least significant side. Each block is replaced by the corresponding hex digit.
Let’s see an example to get the clarity on hexadecimal and binary number representation.
0011 1110 0101 1011 0001 1101
  3    E    5    B   1    D
We write 0X3E5B1D for a hex constant in C language.
Another example which What iss how to convert decimal to binary and then to hexadecimal is as follows −
7529D = 0000 0000 0000 0000 0001 1101 0110 1001B
      = 0x00001D69 = 0x1D69
Following is the C program which What is how the binary number is converted into its equivalent hexadecimal number by using while loop −
 Live Demo
#include <stdio.h>
int main(){
   long int binaryval, hexadecimalval = 0, i = 1, remainder;
   printf("Enter the binary number: ");
   scanf("%ld", &binaryval);
   while (binaryval != 0){
      remainder = binaryval % 10;
      hexadecimalval = hexadecimalval + remainder * i;
      i = i * 2;
      binaryval = binaryval / 10;
   }
   printf("Equivalent hexadecimal value: %lX", hexadecimalval);
   return 0;
}
When the above program is executed, it produces the following result −
Enter the binary number: 11100
Equivalent hexadecimal value: 1C
Get the summary of dataset in R using Dply - GeeksforGeeks

23 Aug, 2021
In this article, we will discuss how to get a summary of the dataset in the R programming language using Dplyr package. To get the summary of a dataset summarize() function of this module is used. This function basically gives the summary based on some required action for a group or ungrouped data, which in turn helps summarize the dataset.
Syntax: summarize(action)
The dataset in use: bestsellers3
Here, action can be any operation to be performed on grouped data, it can be frequency count, mean, average, etc.
Example: Summarize the dataset using summarize()
R
library(dplyr)  data<-read.csv("bestsellers.csv")data %>% group_by(Genre) %>%  summarize(n())
Output:
# A tibble: 2 x 2
 Genre       `n()`
 <fct>       <int>
1 Fiction        82
2 Non Fiction   117
It is also possible to summarize ungrouped data. There are three possible functions that can be used for this.
summarize_all().
summarize_at().
summarize_if().
summarize_all() function summarizes all the columns based on the action to be performed.
Syntax: summarize_all(action)
R
library(dplyr)  data<-read.csv("bestsellers.csv")data %>% group_by(Genre) %>%  summarize_all(mean)
Output:
summarize_at() function is used to apply a required action to some specific columns and generate a summary based on that
Syntax: summarize_at(vector_of_columns,action)
R
library(dplyr)  data<-read.csv("bestsellers.csv")data %>% group_by(Genre) %>%  summarize_at(c('User.Rating','Price'),mean)
Output:
summarize_if() function is used to get dataset summary if a certain condition is specified.
Syntax: summarize_if(condition, action)
R
library(dplyr)  data<-read.csv("bestsellers.csv")data %>% group_by(Genre) %>%  summarize_if(is.numeric, mean)
Output:
Picked
R Dplyr
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
How to filter R dataframe by multiple conditions?
Replace Specific Characters in String in R
Time Series Analysis in R
R - if statement
Can we initialize static variables in a default constructor in Java?

Class/static variables belong to a class, just like instance variables they are declared within a class, outside any method, but, with the static keyword.
They are available to access at the compile time, you can access them before/without instantiating the class, there is only one copy of the static field available throughout the class i.e. the value of the static field will be same in all objects. You can define a static field using the static keyword.
If you declare a static variable in a class, if you haven’t initialized it, just like with instance variables compiler initializes these with default values in the default constructor.
Yes, you can also initialize these values using the constructor.
 Live Demo
public class DefaultExample {
   static String name;
   static int age;
   DefaultExample() {
      name = "Krishna";
      age = 25;
   }
   public static void main(String args[]) {
      new DefaultExample();
      System.out.println(DefaultExample.name); System.out.println(DefaultExample.age);
   }
}
Krishna
25
But if you declare an instance variable static and final Java compiler will not initialize it in the default constructor therefore, it is mandatory to initialize static and final variables. If you don’t a compile time error is generated.
 Live Demo
public class DefaultExample {
   static final String name;
   static final int age;
   public static void main(String args[]) {
      new DefaultExample();
      System.out.println(DefaultExample.name); System.out.println(DefaultExample.age);
   }
}
DefaultExample.java:2: error: variable name not initialized in the default constructor
   static final String name;
            ^
DefaultExample.java:3: error: variable age not initialized in the default constructor
   static final int age;
^
2 errors
But, if you try to initialize a variable which is declared final and static, compiler considers it as an attempt to initialize the variable and a compile time error will be generated.
 Live Demo
public class DefaultExample {
   static final String name;
   static final int age;
   DefaultExample() {
      name = "Krishna";
      age = 25;
   }
   public static void main(String args[]) {
      new DefaultExample();
      System.out.println(DefaultExample.name);
      System.out.println(DefaultExample.age);
   }
}
OutputDeviceAssignedDefaultExample.java:5: error: cannot assign a value to final variable name
   name = "Krishna";
   ^
DefaultExample.java:6: error: cannot assign a value to final variable age
   age = 25;
   ^
2 errors
How can we disable cut, copy and paste functionality of a JTextArea in Java?

A JTextArea is a subclass of the JTextComponent class and it is a multi-line text component to display the text or allow a user to enter the text. A JTextArea can generate a CaretListener interface when we are trying to implement the functionality of the JTextArea. By default, the JTextArea class can support cut, copy and paste functionality, we can also disable or turn off the functionality of cut, copy and paste by using the getInputMap().put() method of JTextArea class. We can use KeyStroke.getKeyStroke("control X") for cut, KeyStroke.getKeyStroke("control C") for copy and KeyStroke.getKeyStroke("control V") for paste.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JTextAreaCutCopyPasteDisableTest extends JFrame {
   private JTextArea textArea;
   private JButton cut, copy, paste;
   private JPanel panel;
   public JTextAreaCutCopyPasteDisableTest() {
      setTitle("JTextAreaCutCopyPasteDisable Test");
      setLayout(new BorderLayout());
      panel = new JPanel();
      textArea = new JTextArea();
      cut = new JButton("Cut");
      cut.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
            textArea.getInputMap().put(KeyStroke.getKeyStroke("control X"), "none");// disable cut 
         }
      });
      panel.add(cut);
      copy = new JButton("Copy");
      copy.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
            textArea.getInputMap().put(KeyStroke.getKeyStroke("control C"), "none"); // disable copy
         }
      });
      panel.add(copy);
      paste = new JButton("Paste");
      paste.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
            textArea.getInputMap().put(KeyStroke.getKeyStroke("control V"), "none"); // disable paste
         }
      });
      panel.add(paste);
      add(panel, BorderLayout.NORTH);
      add(new JScrollPane(textArea), BorderLayout.CENTER);
      setSize(400, 250);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setLocationRelativeTo(null);
      setVisible(true);
   }
   public static void main(String []args) {
      new JTextAreaCutCopyPasteDisableTest();
   }
}