AWT vs Swing Components in Java: Weight Differences

raja
Updated on 06-Feb-2020 10:46:30

2K+ Views

AWT stands for Abstract Window ToolKit and it supports Java GUI programming. It is a portable GUI library for Stand-alone Java applications/applets. The AWT provides the connection between our application and the native GUI while Java Swing implements a set of GUI components that build on AWT technology and it can provide a pluggable look and feel. Java Swing is implemented entirely in the Java programming language.First of all, by a heavy-weight, it means the code will take comparatively more time to load and it will consume more System resources. AWT is considered to be heavy-weight because its components are dependent ... Read More

Maximum Length of Identifiers in MySQL

Smita Kapse
Updated on 06-Feb-2020 10:31:07

646 Views

As we know that certain objects within MySQL are known as identifiers. These objects include a database, table, index, column, alias, view, stored procedure, partition, tablespace etc. Identifiers are stored using Unicode (UTF-8). The maximum length of each type of identifier is given in the following table:Sr. No.IdentifierMaximum Length (characters)1Database642Table643Column644Index645Constraint646Stored Procedure or Function647Trigger648View649Event6410Tablespace6411Log File Group6412Alias25613Compound Statement Label16

Why the Constructor Name is Same as the Class Name in Java

raja
Updated on 06-Feb-2020 10:09:33

4K+ Views

Every class object is created using the same new keyword, so it must have information about the class to which it must create an object. For this reason, the constructor name should be the same as the class name.Exampleclass MyConstructor{    public MyConstructor() {       System.out.println("The constructor name should be same as the class name");    }    public static void main(String args[]){       MyConstructor mc = new MyConstructor();    } }In the above program, the constructor name should be the same as the class name (MyConstructor).OutputThe constructor name should be same as the class name

Scope and Lifetime of Variables in Java

raja
Updated on 06-Feb-2020 09:24:32

10K+ Views

Instance VariablesA variable which is declared inside a class and outside all the methods and blocks is an instance variable. The general scope of an instance variable is throughout the class except in static methods. The lifetime of an instance variable is until the object stays in memory.Class VariablesA variable which is declared inside a class, outside all the blocks and is marked static is known as a class variable. The general scope of a class variable is throughout the class and the lifetime of a class variable is until the end of the program or as long as the ... Read More

Padding Functions in SQL: LPAD and RPAD Behavior

Samual Sam
Updated on 06-Feb-2020 06:54:02

349 Views

In this case, MySQL will not pad anything and truncate the characters from the original string up to the value of length provided as the argument in LPAD() or RPAD() functions.Examplemysql> Select LPAD('ABCD',3,'*'); +--------------------+ | LPAD('ABCD',3,'*') | +--------------------+ | ABC                | +--------------------+ 1 row in set (0.00 sec) mysql> Select RPAD('ABCD',3,'*'); +--------------------+ | RPAD('ABCD',3,'*') | +--------------------+ | ABC                | +--------------------+ 1 row in set (0.00 sec)We can observe from the above example that both the functions do not pad ‘*’ and truncate the original string up to the length specified i.e. 3 as the argument.

Use LPAD and RPAD Functions in MySQL

Ankith Reddy
Updated on 06-Feb-2020 06:53:27

810 Views

For using LPAD() or RPAD() functions with the column values we need to specify the column name as the first argument of these functions. Following the example from ‘Student’ table will make it clearer −Examplemysql> Select Name, LPAD(Name, 10, '*') from student; +---------+-------------------+ | Name    | LPAD(Name, 10, '*') | +---------+-------------------+ | Gaurav  | ****Gaurav        | | Aarav   | *****Aarav        | | Harshit | ***Harshit        | | Gaurav  | ****Gaurav        | | Yashraj | ***Yashraj        | +---------+-------------------+ 5 rows in set (0.08 ... Read More

Use LTRIM and RTRIM Functions to Update MySQL Table

Akshaya Akki
Updated on 06-Feb-2020 06:52:34

458 Views

We can use LTRIM() and RTRIM functions with MySQL update clause so that the values, after removing space characters, in the table can be updated. Following examples will demonstrate it −ExampleSuppose we know that there can be some space characters in the values of ‘Name’ column of table ‘Student’ then with the help of following single query we can remove the space characters from that column’s value and also update the table −mysql> Update Student SET Name = LTRIM(Name); Query OK, 0 rows affected (0.07 sec) Rows matched: 5 Changed: 0 Warnings: 0 mysql> Update Student SET Name = ... Read More

Remove Leading and Trailing Spaces from a String in MySQL

Anjana
Updated on 06-Feb-2020 06:48:49

150 Views

Other than LTRIM() and RTRIM() functions, MySQL has TRIM() function to remove leading and trailing function both at once from a string. The use of TRIM() function can be understood from the following example of a test_trim table which has a column ‘Name’ containing the names with leading and trailing spaces.Examplemysql> Select Name, TRIM(Name)AS 'Name Without Spaces' from test_trim; +---------------+---------------------+ | Name          | Name Without Spaces | +---------------+---------------------+ | Gaurav        | Gaurav              | | Rahul         | Rahul               | | Aarav         | Aarav               | +---------------+---------------------+ 3 rows in set (0.00 sec)

Use MySQL TRIM to Remove Whitespace and Update Table

Alankritha Ammu
Updated on 06-Feb-2020 06:48:17

294 Views

Suppose if a table has many values having whitespaces in the columns of a table then it is wastage of space. We can use TRIM() function to remove whitespaces from all the rows and update the table too in a single query. Following the example from ‘Employee’, having whitespaces in all its rows will exhibit the concept −Examplemysql> Select * from Employee; +------+----------------------+----------------------+----------------------+ | Id   | Name                 | Address              | Department           | +------+----------------------+----------------------+----------------------+ | 100  | Raman       ... Read More

Significance of Using Multiple Columns in MySQL GROUP BY Clause

Ankith Reddy
Updated on 06-Feb-2020 06:45:51

233 Views

By specifying multiple columns in GROUP BY clause we can split the result set into smaller groups. The more columns specified in GROUP BY clause, the smaller the groups will be.Examplemysql> Select designation, YEAR(Doj), count(*) from employees GROUP BY designation, YEAR(DoJ); +-------------+-----------+----------+ | designation | YEAR(Doj) | count(*) | +-------------+-----------+----------+ | Asso.Prof   | 2013      | 1        | | Asst.Prof   | 2015      | 1        | | Asst.Prof   | 2016      | 1        | | Prof        | 2009      | 2        | | Prof        | 2010      | 1        | +-------------+-----------+----------+ 5 rows in set (0.00 sec)

Advertisements