Samual Sam has Published 2492 Articles

Display Java Specification Version

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

288 Views

Use the System.getProperty() method in Java to get the Java Specification Version.It’s syntax is −String getProperty(String key)Above, the key is the name of the system property. Since, we want the Java Specification Version name, therefore we will add the key as −java.specification.versionThe following is an example −Example Live Demopublic class Demo ... Read More

MySQL: delete all rows containing string “foo” in sample table “bar”?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

1K+ Views

To delete all rows containing string “foo” in table “bar”, you need to use LIKE operator.To understand the above syntax, let us create a sample table with name “bar”. The query to create a table is as follows. We will always insert records with string “foo” using INSERT command after ... Read More

Format numerical data with printf in Java

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

87 Views

First, we have taken a double variable and displayed it twice.double d = 399.8877; System.out.printf("d1 = %2$f d2 = %1$g", d, d);After that, we have formatted numerical int data −int val1 = 90, val2 = 35, val3 = 88, val4 = 600; System.out.printf("val1 = %d, val2 = %x, val3 = ... Read More

Java Program to get Operating System name and version

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

2K+ Views

Use the System.getProperty() method in Java to get the Operating System name and version.It’s syntax is −String getProperty(String key)Above, the key is the name of the system property. Since, we want the OS name and version, therefore we will add the key as −Operating System name - os.name Operating System ... Read More

Writing files in background in Python

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

140 Views

Here we are trying to do two tasks at a time, one in the foreground and the other in the background. We’ll write something in the file in the background and of a user input number, will find if it’s an odd or even number.Doing multiple tasks in one program ... Read More

Get localized day name in Java

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

143 Views

The following is an example.Example Live Demoimport java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; public class Demo { public static void main(String[] args) throws Exception { Date d = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss a"); ... Read More

REGEX Match integers 6 through 10 in MySQL?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

93 Views

Here you can use BETWEEN operator. The syntax is as follows −SELECT *FROM yourTableName WHERE yourColumnName BETWEEN 6 AND 10;You can use regular expression like this. The syntax is as follows −SELECT *FROM yourTableName WHERE yourColumnName REGEXP '10|[6-9]';To understand the both syntax, let us create a table. The query to ... Read More

Get Java Home Directory

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

786 Views

Use the System.getProperty() method in Java to get the Java Home Directory.It’s syntax is −String getProperty(String key)Above, the key is the name of the system property. Since, we want the Java Home Directory name, therefore we will add the key as −java.homeThe following is an example −Example Live Demopublic class Demo ... Read More

MySQL update query to remove spaces between letters?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

3K+ Views

If you have spaces between letters then you can use REPLACE() function to remove spaces.The syntax is as follows −UPDATE yourTableName SET yourColumnName=REPLACE(yourColumnName, ’ ‘, ’’);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table removeSpaceDemo ... Read More

Java Program to return a Date set to the first possible millisecond of the month after midnight

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

113 Views

Use the getMaximum() method in Java to returns the maximum value for the given calendar field. We will use it to set the minute, second and milliseconds.Let us first declare a calendar object −Calendar dateNoon = Calendar.getInstance();Now, we will set the hour, minute, second and millisecond to the first possible ... Read More

Advertisements