Friday, September 12, 2008

String in java

String is Immutable and String Is a final class. The String class provides for strings whose value will not change.
One accessor method that you can use with both strings and string buffers is the length() method, which returns the number of characters contained in the string or the string buffer.

The methods in String Class:-
toString( )
equals( )
indexOff( )
LowerCase( )
charAt( )
compareTo( )
lastIndexOff( )
UpperCase( )
getChars( )
subString( )
trim( )
getBytes( )
concat( )
valueOf( )
toCharArray( )
replace( )

Tuesday, September 9, 2008

Data Encapsulation in JAVA

What is data encapsulation?
The most common example I can think of is a javabean. Encapsulation may be used by creating 'get' and 'set' methods in a class which are used to access the fields of the object. Typically the fields are made private while the get and set methods are public.
Encapsulation can be used to validate the data that is to be stored, to do calculations on data that is stored in a field or fields, or for use in introspection (often the case when using javabeans in Struts, for instance).

private methods on Interface

  Private methods can be used on interface from java 9.   This will help in     Avoiding code duplication.     Ensuring code re-usab...