Tip Bank

DevX - Software Development Resource

Add an AutoIncrement Column to a DataTable

Adding an AutoIncrement column to a DataTable is quite simple: When you create a DataColumn, set its AutoIncrement property to true. The following code demonstrates: DataColumn posId = table.Columns.Add(“PositionId”, typeof(int));posId.AutoIncrement

DevX - Software Development Resource

Adding Custom Attributes to HTML Elements

A custom attribute is any user-defined attribute, just like other primitive HTML element attributes. You can add custom attributes to any HTML element. For example, suppose you wanted to add

DevX - Software Development Resource

Associate a ServerSocket with a ServerSocketChannel in an NIO App

This tip shows you how to create a ServerSocketChannel, to which you’ll then associate a standard ServerSocket: //create the ServerSocketChanneltry{ serverNIO=ServerSocketChannel.open(); serverNIO.configureBlocking(false); }catch(IOException e) {System.out.println(” Error: ” + e.getMessage());}//indicate the

DevX - Software Development Resource

How to Use Properties Files in Java

In Java, you can easily create and use a properties file containing name/value pairs. First, make a .properties file?name it Properties.properties. Place key/value pairs such as name = java in

DevX - Software Development Resource

Truncate a Path String

Sometimes you need to truncate a long path string to make it fit in a control. Currently, there is no .NET class that provides this functionality. The workaround is to

DevX - Software Development Resource

Using the Final Keyword in Java

Contrary to popular opinion, the compiler cannot safely inline methods that have been declared as final. This is because these methods may have non-final declarations at runtime. For example, suppose

DevX - Software Development Resource

Trimming Items in a String Array

When you use a For Each loop to iterate through a String Array and perform some action with each item, the change doesn’t affect the String Array itself. Consider the

DevX - Software Development Resource

Changing the Style of a String in JavaScript

JavaScript’s String object provides functions that display style of the text: big() blink() bold() fixed() fontsize(&ltsize&gt): This function takes a parameter to specify the font-size in pixels. fontcolor(““): This function