The HTML DOM KeyboardEvent loaction property returns the number corresponding to location of key pressed on the keyboard.SyntaxFollowing is the syntax −Returning location of pressed key −event.locationNumbersHere, number returned can be the following −numberDescriptions0It represents almost all values on the keyboard. (every key in the middle section of keyboard, eg: ‘Q’, ’\’, ’spacebar’)1It represents the values on the left-keyboard. (every key in the left section of keyboard, eg: ‘left ctrl’, ’left Shift’, ’left alt’)2It represents the values on the right-keyboard. (every key in the right section of keyboard, eg: ‘right ctrl’, ’right Shift’, ’right alt’)3It represents the values on the ... Read More
When we execute certain SQL queries (SELECT query in general) they return tabular data.The java.sql.ResultSet interface represents such tabular data returned by the SQL statements.i.e. the ResultSet object holds the tabular data returned by the methods that execute the statements which quires the database (executeQuery() method of the Statement interface in general).The ResultSet object has a cursor/pointer which points to the current row. Initially this cursor is positioned before first row.The deleteRow() method of the ResultSet interface deletes the current row from the ResultSet object and from the table.rs.deleteRow();Let us create a table with name MyPlayers in MySQL database using CREATE statement as ... Read More
To make MySQL table primary key auto increment, use the below syntaxCREATE TABLE yourTableName ( yourColumnName INT(6) ZEROFILL NOT NULL AUTO_INCREMENT, PRIMARY KEY(yourColumnName) );Let us first create a table and set primary key auto increment −mysql> CREATE TABLE DemoTable ( UserId INT(6) ZEROFILL NOT NULL AUTO_INCREMENT, PRIMARY KEY(UserId) ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command −mysql> INSERT INTO DemoTable values(); Query OK, 1 row affected (0.12 sec) mysql> INSERT INTO DemoTable values(); Query OK, 1 row affected (0.13 sec) mysql> INSERT ... Read More
Yes, it's possible to assign a numeric value to an enum.Enum in Java is used to represent a list of predefined values. Most of the time, we probably not care about the associated value of an enum. However, there might be some times when we need to assign specific values to an enum.Example:import java.util.Enumeration; import java.util.Vector; public class EnumerationExample { public static void main(String[] args) { Vector vec = new Vector(4); vec.add(4); vec.add(3); vec.add(2); vec.add(1); Enumeration e = vec.elements(); ... Read More
Let us first create a panel and set some buttons −JPanel panel = new JPanel(); JButton btn1 = new JButton("One"); JButton btn2 = new JButton("Two"); JButton btn3 = new JButton("Three"); JButton btn4 = new JButton("Four"); JButton btn5 = new JButton("Five"); panel.add(btn1); panel.add(btn2); panel.add(btn3); panel.add(btn4); panel.add(btn5);Now, use the setAlignmentX() and within that specify alignment to the center of the component −panel.setAlignmentX(Component.CENTER_ALIGNMENT);The following is an example to center align component using BoxLayout −Examplepackage my; import java.awt.Component; import java.awt.Dimension; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class SwingDemo { public static void main(String[] args) { ... Read More
The strokeStyle property in HTML canvas is used to set the color, gradient or pattern for the stroke. The element allows you to draw graphics on a web page using JavaScript. Every canvas has two elements that describes the height and width of the canvas i.e. height and width respectively.Following is the syntax −context.strokeStyle=color|gradient|pattern;Above, the values, include −color − The stroke color of the drawing.gradient − Linear or radial gradient object to create gradient strokepattern − The pattern object to create pattern stroke.Let us now see an example to implement the strokeStyle property of canvas −Example Live Demo ... Read More
Calculating number of vowels in a stringVowels in English language are a, e, i, o and u. Make sure that, in any string these vowels can be both cases ( either small or capital). DebriefThe following example, using a user defined function called 'noOfVowels()', reads an input string and compares that string with another string which contains only vowels( 'aAeEiIoOuU'). It takes the help of indexOf() method to proceed the task. The indexOf() method displays index of a character whenever the character is common to both the strings, in unmatched case it displays '-1' as the output. Here it compares each and ... Read More
Overloading is a one of the mechanisms to achieve polymorphism where, a class contains two methods with same name and different parameters.Whenever you call this method the method body will be bound with the method call based on the parameters.Overloading private methodsYes, we can overload private methods in Java but, you can access these from the same class.Example Live Demopublic class Calculator { private int addition(int a , int b){ int result = a+b; return result; } private int addition(int a , int b, int c){ int result = ... Read More
To delete all rows older than 30 days, you need to use the DELETE with INTERVAL. Use < now() i.e. less than operator to get all the records before the current date.Let us first create a table −mysql> create table DemoTable -> ( -> UserMessage text, -> UserMessageSentDate date -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Hi', '2019-06-01'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Hello', '2019-07-02'); Query OK, 1 row affected (0.14 sec) mysql> insert ... Read More
The HTML DOM input checkbox checked property returns and alter the value of checked attribute of a checkbox in HTML.syntaxFollowing is the syntax −1. Returning checkedobject.checked2. Altering checkedobject.checked = true|falseExampleLet us see an example of HTML DOM Input Checkbox checked property − Live Demo HTML DOM checked property body{ text-align:center; } p{ font-size:1.5rem; color:#ff8741; } input{ width:30px; height:30px; } button{ background-color:#db133a; color:#fff; padding:8px; border:none; ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP