devxlogo

We are an award-winning tech entrepreneurship website where trusted experts can provide value globally.

Since 1998, DevX has helped people start businesses, build websites, and provide enterprise technology to people globally. Interviewing the likes of Microsoft’s co-founder, Steve Ballmer, the publication brings comprehensive, reliable, and accessible insights to the Internet.

devxlogo

Trusted for 26 years

Over 30K Articles

1M+ Readers

Expert-reviewed

10K+ Tech Terms

As seen in:

microsoft logo
business_insider_logo
wired_logo
berkley
arstechnica_logo
hackernoon

The Latest

Get Packages of a Module

Java 9 has added the concept of module via Java Platform Module System. In order to obtain the names of packages from a module we can do it as follows:

Get Current Language ID

You can get the language ID with the following Select statement: SET LANGUAGE ‘French’SELECT @@LANGID AS ‘Language ID’

Understanding the Feature-rich Methods of Math Package

The Math package is feature-rich and some of the methods are illustrated below. public class MathPkg{public static void main(String args[]){MathPkg mathPkg = new MathPkg();mathPkg.proceed();}private void proceed(){int positiveNum = 5;int negativeNum

What is the Advantage of Immutability?

It is difficult to maintain correctness in mutable objects, as multiple threads could be trying to change the state of the same object. This can lead to some threads seeing

Using sys.dm_db_index_physical_stats

Using dm_db_index_physical_stats?returns size and fragmentation information for the data and indexes of the specified table or view in SQL Server. USE master; GO — If Student.Name does not exist in

Swapping Two Numbers

Swapping two numbers without using a new variable is always a good approach. This helps your application to be memory and performance oriented. public class Swap2Numbers{ int firstNum = 10;

Get All the Available Time Zones

Before Java 8, this was obtained as a String[] via TimeZone class: String[] zoneIds = TimeZone.getAvailableIDs(); Java 8 comes with a new approach via java.time.ZoneId class: Set zoneIds = ZoneId.getAvailableZoneIds();

Write SQL Results to a Text file

You can write results of a SELECT query into a text file in the following way: master..xp_cmdshell ‘osql -S SERVERNAME -U USERNAME -P PASSWORD -Q “SELECT * FROM TABLE” -d

Enumerate All the Values in an Enum

See an easy way to enumerate all the values. public enum WorkTypes{Remote = 0,Office = 1,Exempted = 2}foreach (WorkTypes workType in Enum.GetValues(typeof(WorkTypes)))Console.WriteLine(workType);

Avoid NPE via JDK 8, Optional

Starting with JDK 8, you can avoid NullPointerException by returning an Optional. For example, instead of returning null, this method returns an empty Optional: public Optional fetchShoppingCart(long id) { ShoppingCart

Diagnose System Slowdowns

One good way to quickly diagnose System slowdowns is to make use of the sp_who2 SQL function in the following way: EXEC sp_who2 This helps identify High CPU Usage, Blocking

Get a Special Folder Path in C#

Use the System.Environment namespace’s GetFolderPath?method to retrieve the path of a special folder. It can also create the folder if it does not exist. System.Environment.GetFolderPath(Environment.SpecialFolder.Recent, Environment.SpecialFolderOption.None))

Understanding the FindAny Method

Learn how to use the findAny method in java.util.Stream. This returns an Optional describing an element, or an empty Optional if Stream is empty. Also, remember that the same stream

Escape Characters in Regular Expressions

In Java, characters as  cannot appear in a regular expression without being escaped. For this, rely on the Pattern.quote() method as in the following example: public static boolean contains(String t1, String

Identify Tables Storing GUID Values

You can identify tables that store a GUID (Globally Unique Identifier) value with the following script: SELECT [table] = s.name + N’.’ + t.nameFROM sys.tables AS tINNER JOIN sys.schemas AS

Finding the Java Version Programatically

import java.util.*;public class FindJavaVersion{ public static void main(String args[]) { FindJavaVersion findJavaVersion = new FindJavaVersion(); findJavaVersion.printDetails(); } private void printDetails() { Properties systemProperties = System.getProperties(); System.out.println(“Java version: ” + systemProperties.get(“java.version”));

Using sys.dm_db_missing_index_group_stats

Using sys.dm_db_missing_index_group_stats?returns summary information about groups of missing indexes, excluding spatial indexes. An example follows: SELECT TOP 5 * FROM sys.dm_db_missing_index_group_stats ORDER BY avg_total_user_cost * avg_user_impact * (user_seeks + user_scans)

Quickly View All TODOs in Visual Studio

TODOs are a quick way to jot down action items while coding. It can also sometimes become cumbersome to locate all TODOs for further action. Visual Studio provides a way

Counting Digits in a Given Number

A typical mechanism of converting to a string, traversing and counting has a lot of processing to complete. Instead, the code below shows a combination of methods in Math package

Return Response Codes from ASP.NET Action Result Using StatusCodes Enum

The Microsoft.AspNetCore.Http.StatusCodes?enum has many response codes. Please see below for an example to return one of the values from the enum: [HttpGet]public IActionResult CustomStatusCode (){ //code”return StatusCode(Microsoft.AspNetCore.Http.StatusCodes.Status405MethodNotAllowed);}

Finding the Available Drive Types in the System

Getting to know the available drive types in the system is essential for certain activities in Java. The following code snippet lists the available drive types in the system: */import

Boost the Switch Statement in JDK 12

Starting with JDK 12, the “switch” statement is extended so that it can be used as either a statement or an expression. A sample: switch (day) { case MONDAY, FRIDAY,

Using the DATALENGTH SQL Function

The DATALENGTH SQL returns the length of columns in a table. SELECT length = DATALENGTH(ColumnName) FROM TableName ORDER BY ColumnName

Quickly Tell Team Something About Code

Visual Studio allows you to communicate with fellow developers about a piece of code. It lets you add a compiler directive “warning” to your code, which shows up in the