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

How to Prevent a Class From Serialization

The following code prevents classes from serialization: public class MyClass implements Serializable{//you can write your code hereprivate void writeObject(ObjectOutputStream out) throws IOException{ throw new NotSerializableException();}private Object readObject(ObjectInputStream in) throws IOException,ClassNotFoundException{

Examine the Number of Extents in a Table

The amount of time it takes to retrieve data blocks is proportionate to the number of extents in the table. Ideally, a table should have one to three extents. Run

Customizing JFileChooser

The class JFileChooser inside javax.swing.* can be customized to display your own labels using the UIManager.put() method. It is a static method that takes an Object key (Original value) and

Eliminating Duplicate Values

To eliminate duplicate values in a collection, Java provides it own API. HashSet (java.util.*) is the class which implements Set interface. import java.util.*;class Duplicate{ static void main(String[]arr){ HashSet set=new HashSet();

“Shrink” the Size of a File

Visual Basic lacks the ability to make a file smaller without having to recreate it. But it is possible to use the SetEndOfFile API. Here is a function for it:

Generic Name Property Procedure with TypeName

One easy way to implement a generic name property of a class is to make a property procedure with TypeName function. Public Property Get Name() As String Name = TypeName(Me)End

A Super-Efficient Toggle Case Using XOR

My benchmarking shows that ToggleCase can crunch through a 2,000,000character string in under 4 seconds on a Pentium II. Public Function ToggleCase(ByVal strData As String) As String ‘This technique gets

Warnings Regarding Temporaries and Their Meaning

The following code causes a somewhat cryptic warning message: struct Employee{ long ID; string name;};Employee emp;void func(int& id) { id=0;}// warning below issued for the following call:func(emp.ID);

Right-Justification of Output

To right justify the output of cout, call the width() function with the size of the output screen (in characters) as an argument. In the following example, the program calls

What You Should Include in a Header File

A header file should begin and end with #include guards to guarantee that it’s not #included more than once during the same compilation session. A typical #include guard looks as

Enumerate Collections With For Each…Next

It’s faster to enumerate a collection with the For each…Next statetment: Dim c As Class1 For Each c In Col ‘Code… NextDim fldField As ADODB.Field For Each fldField In rsTemp

Alternatives to ios::nocreate and ios::noreplace

In pre-standard C++, certain implementations of offered the flags ios::nocreate and ios::noreplace for controlling file creation. These flags were too platform-specific and never made it into the standard library, which

Standard Exit Codes

C++ defines the symbolic constants EXIT_SUCCESS and EXIT_FAILURE that you can use as return codes. These macros are defined in the header file ( in C) as follows: #define EXIT_SUCCESS

Deleting Elements of a Container of Pointers

This is a common source of misunderstanding: a programmer creates a container of pointers, then fills that container with pointers to dynamically allocated objects. When the container is destroyed, the

Namespaces and the C Standard Library

The C++ Standard requires that the C standard library be declared in namespace std, just as the C++ Standard Library. Thus, if you #include and call printf(), you should use

Arrays of Pointers to Members

You can create an array of pointers to member just as you would create arrays of any other type. The following example creates an array of pointers to member functions

Filtering Input in scanf()

You can force scanf() to read only specific characters from the input source while ignoring all the rest. Alternatively, you can force scanf() to read all input characters except the

Where are std::min() and std::max()?

The Standard Library defines the two template functions std::min() and std::max() in the header. In general, you should use these template functions for calculating the min and max values of

Pop Goes the Menu

HTML pop-up menus are becoming more common in Web applications because they expand the available screen area by placing destination links in an invisible but easily accessed location. However, the

AreaFill – Fill an area with a solid color

Private Declare Function ExtFloodFill Lib “GDI32” (ByVal hDC As Long, _ ByVal X As Long, ByVal Y As Long, ByVal colorCode As Long, _ ByVal fillType As Long) As LongConst

MakeModalForm – Make a modeless form modal

‘ make a modeless form modal” this procedure should be called by passing TRUE’ in the 2nd argument to make the form modal, and’ called again with FALSE in the

Create multiple controls of same type

When you plan to create more control of the same type you can save some clicks by selecting the control on the Toolbox with the mouse while you press the