Difference Between String, StringBuffer, and StringBuilder Classes in Java

Narasimha Murthi
Updated on 30-Jul-2019 22:30:26

699 Views

The String class of the java.lang package represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class. Strings are constant, their values cannot be changed after they are created.The StringBuffer and StringBuilder classes are used when there is a necessity to make a lot of modifications to Strings of characters.Unlike Strings, objects of type StringBuffer and String builder can be modified over and over again without leaving behind a lot of new unused objects.The StringBuilder class was introduced as of Java 5 and the main difference between the StringBuffer and StringBuilder ... Read More

Find Specific Row with Multiple IDs in MySQL

Rama Giri
Updated on 30-Jul-2019 22:30:26

151 Views

To find a row, use FIND_IN_SET(). Let us first create a table −mysql> create table DemoTable    -> (    -> ListOfIds varchar(200)    -> ); Query OK, 0 rows affected (0.72 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('100, 2093, 678, 686'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('0595, 9585, 4885, 95959'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('0059954, 95986884, 9059596, 9005'); Query OK, 1 row affected (0.20 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+-------------------------------+ ... Read More

HTML DOM Input datetime-local Form Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

149 Views

The HTML DOM Input DatetimeLocal form property returns the reference of enclosing form for input DatetimeLocal.SyntaxFollowing is the syntax −Returning reference to the form objectinputDatetimeLocalObject.formExampleLet us see an example of Input DatetimeLocal form property − Live Demo Input DatetimeLocal form    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } Datetime-Local-form Examination Time: ... Read More

Convert MM-DD-YY to Unix Timestamp in MySQL

Chandu yadav
Updated on 30-Jul-2019 22:30:26

428 Views

To convert MM/DD/YY to UNIX timestamp, you can use the below syntax −select UNIX_TIMESTAMP(str_to_date(yourColumnName, '%m/%d/%Y')) from yourTableName;Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    dateConvertToUnix varchar(100)    ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(dateConvertToUnix) values('01/10/2001'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(dateConvertToUnix) values('03/31/2010'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(dateConvertToUnix) values('12/31/2016'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(dateConvertToUnix) values('04/27/2019'); Query OK, 1 ... Read More

Get Combined Field Result in MySQL

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

173 Views

You can use CONCAT() function from MySQL for this. Let us first create a table −mysql> create table DemoTable    (    ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ClientFirstName varchar(20),    ClientLastName varchar(20)    ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('John', 'Smith'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('John', 'Miller'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('Carol', 'Taylor'); Query OK, 1 row affected (0.13 sec) mysql> insert into ... Read More

Align Multiple Buttons with Different Height in Java

Smita Kapse
Updated on 30-Jul-2019 22:30:26

617 Views

To align multiple buttons with different height in Java, try the following example, Here, we have set 5 buttons with GridBagConstraints −GridBagConstraints constraints = new GridBagConstraints(); constraints.insets = new Insets(5, 5, 5, 5); constraints.anchor = GridBagConstraints.WEST;In addition, to set different height for different buttons, we have used −component. getPreferredSize().heightThe following is an example to align multiple buttons with different height −Examplepackage my; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class SwingDemo {    public static void main(String[] args) {       final JFrame frame = new JFrame(SwingDemo.class.getSimpleName());       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       JPanel panel = new JPanel(new GridBagLayout());       GridBagConstraints constraints = new GridBagConstraints();       constraints.insets = new Insets(5,  5,  5,  5);       constraints.anchor = GridBagConstraints.WEST;     ... Read More

Add Two Consecutive Bytes of an Array in 8085

Chandu yadav
Updated on 30-Jul-2019 22:30:26

857 Views

Here we will see how we can add two consecutive elements in an array using 8085.Problem StatementWrite 8085 program to add two consecutive elements of an array and store them in the same location. The carry will be placed at bottom of the other byte. The numbers are stored from location 8001. The size of array is stored at 8000.DiscussionHere we will solve this problem by using one subroutine. That will add two consecutive numbers and stored them into correct position. That subroutine will be called multiple times to add all consecutive pairs. The task will be followed half of ... Read More

Get First Two Highest Column Values from a Table in MySQL

Kumar Varma
Updated on 30-Jul-2019 22:30:26

521 Views

To get the first two highest columns, use ORDER BY. With that, use LIMIT 2 to get only the first 2 −select *from yourTableName order by yourColumnName DESC LIMIT 2;Let us first create a table −mysql> create table DemoTable    -> (    -> Value int    -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(90); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(70); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable values(40); Query OK, 1 row affected ... Read More

HTML DOM Input datetime-local max Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

166 Views

The HTML DOM Input DatetimeLocal max property returns/sets max attribute of Input DatetimeLocal.SyntaxFollowing is the syntax −Returning string valueinputDatetimeLocalObject.maxSetting max to string valueinputDatetimeLocalObject.max = YYYY-MM-DDThh:mm:ssString ValuesHere, “YYYY-MM-DDThh:mm:ss” can be the following −stringValueDetailsYYYYIt defines year (eg:2006)MMIt defines month (eg: 06 for June).DDIt defines Day (eg: 17)TIt is a separator for date and timehhIt defines hour (eg:02)mmIt defines minutes (eg:21)ssIt defines seconds (eg:40)ExampleLet us see an example of Input DatetimeLocal max property − Live Demo Input DatetimeLocal max    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * ... Read More

HTML DOM kbd Object

AmitDiwan
Updated on 30-Jul-2019 22:30:26

139 Views

The Kbd Object represents an inline element which displays monospace font by default.SyntaxFollowing is the syntax −Creating a elementvar kbdObject = document.createElement(“KBD”)ExampleLet us see an example for Kbd object element − Live Demo Kbd Object    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } Kbd Object Keyboard Input:    var divDisplay = document.getElementById("divDisplay");    var textSelect = document.getElementById("textSelect");    function convertKBD() {       var kbdObject = document.createElement("KBD");       var kbdText = document.createTextNode(textSelect.value);       kbdObject.appendChild(kbdText);       divDisplay.appendChild(kbdObject);    } OutputThis will produce the following output −Before clicking ‘Check’ button −After clicking ‘Check’ button −

Advertisements