To remove last char if it is a specific character then use SUBSTRING(). Let us first create a table −mysql> create table DemoTable ( SubjectName varchar(100) ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('MySQL'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('MongoDB?'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('Java?'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('C'); Query OK, 1 row affected (0.16 sec)Display all records from the table using select ... Read More
The width attribute of the element is only used with image and allows you to set the width of the image added using −The width attribute introduced in HTML5 and acts as the submit button. Following is the syntax −Above, width represents the width in pixels.Let us now see an example to implement the width attribute of the element wherein the width is set for input type image −Example Live Demo Register Id − Password − DOB − Telephone − Email − ... Read More
The read() method of the input stream classes reads the contents of the given file byte by byte and returns the ASCII value of the read byte in integer form. While reading the file if it reaches the end of the file this method returns -1.ExampleAssume we have a text file (sample.txt) in the current directory with a simple text saying “Hello welcome”. Following Java program reads the contents of the file byte by byte using the read() method and prints the integer value returned for each byte.Since we are not checking for end of the file, the read() method ... Read More
The HTML DOM Location href property returns/sets the string corresponding to the URL path.SyntaxFollowing is the syntax −Returning value of the href propertylocation.hrefValue of the href property setlocation.href = hrefExampleLet us see an example for Location href property − Live Demo Location href form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } Location-href Current URL: var divDisplay = document.getElementById("divDisplay"); var urlSelect = document.getElementById("urlSelect"); function gethref(){ divDisplay.textContent = 'URL Path: '+location.href; } OutputThis will produce the following output −Before clicking ‘Get href’ button −After clicking ‘Get href’ button −
To check if the second item is selected i.e. index 1, use the method isSelectedIndex():list.isSelectedIndex(1);Above, we have set the list with string values:String sports[]= { "Squash", "Fencing", "Cricket", "Football", "Hockey", "Rugby"}; JList list = new JList(sports);The following is an example to check if the second item is selected in JList:Examplepackage my; import java.awt.event.*; import java.awt.*; import javax.swing.*; class SwingDemo extends JFrame { static JFrame frame; static JList list; public static void main(String[] args) { frame = new JFrame("JList Demo"); SwingDemo s = new SwingDemo(); JPanel panel = ... Read More
This mbrtowc() function is used to convert multibyte sequence to wide character string. This returns the length of the multibyte characters in byte. The syntax is like below.mbrtowc (wchar_t* wc, const char* s, size_t max, mbstate_t* ps)The arguments are −wc is the pointer which points where the resulting wide character will be stored.s is the pointer to multibyte character string as inputmax is the maximum number of bytes in s, that can be examinedps is pointing to the conversion state, when interpreting multibyte string.Example#include using namespace std; void display(const char* s) { mbstate_t ps = mbstate_t(); // initial ... Read More
ResultSet holdability determines whether the ResultSet objects (cursors) should be closed or held open when a transaction (that contains the said cursor/ResultSet object) is committed using the commit() method of the Connection interface.The getHoldability() method of the Connection interface is used to retrieves and returns the current holdability value of the ResultSet objects in this connection.This method returns an integer value representing the current ResultSet holdability which will be either 1 or 2 where, 1 indicates the value HOLD_CURSORS_OVER_COMMIT.If the holdability of the ResultSet object is set to this value. Whenever you commit/save a transaction using the commit() method of the Connection ... Read More
slice()The slice() method extracts a part of a string and returns the extracted part in a new string.It doesn't modify the original string.syntaxslice() takes two parameters one is starting index and the other is ending index. It's notation is given below. string.slice(string.slice(starting index, ending index))Arguments a) starting index: It gives from which index string extraction should be started. b) ending index: It gives before which index string extraction should be ended.Example-1In the following example, slice() method slice the given string in to new string starting from index 18 to 26 (27-1) there by giving "Neuralink" as the output. Live Demo ... Read More
To separate components in a row or column, use the createGlue() method. This creates an invisible "glue" component that separates components.The following is an example to separate components in a row or column with Box −Examplepackage my; import java.awt.BorderLayout; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JScrollPane; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Matches"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button1 = new JButton("CSK"); JButton button2 = new JButton("DC"); JButton button3 = new JButton("MI"); JButton ... Read More
Let us first create a collection with documents −> db.matchingFirstItemInTheArrayDemo.insertOne( { "ClientDetails": [ { "ClientName": "Larry", "ClientAge":28 } ] } ); { "acknowledged" : true, "insertedId" : ObjectId("5cd7a5d26d78f205348bc636") } > db.matchingFirstItemInTheArrayDemo.insertOne( { "ClientDetails": [ { "ClientName": "Chris", "ClientAge":56, } ] } ); { "acknowledged" : true, "insertedId" : ObjectId("5cd7a5f56d78f205348bc637") } > db.matchingFirstItemInTheArrayDemo.insertOne( ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP