attention@computerscienceexpertise.com PDF created with pdfFactory Pro trial version www.pdffactory.com
CONSTRUCTOR TYPES
a. Overloaded Constructors:
Under this format the constructor methods are utilized to initialize the object using the parameter argument. The arguments are passed to the constructors and appropriate constructor is invoked by matching the number, types and order of the arguments specified in each method definition.
b. Default Constructors:
The default constructors are used to initialize all the variables to a 0 value. As per the procedure in Java all variables must be initialized when the object is initialized. This is compulsory and it is done by use of a constructor.
attention@computerscienceexpertise.com PDF created with pdfFactory Pro trial version www.pdffactory.com
STRING Manipulation
JAVA offers string manipulation using
the functions.
In order to declare a string variable
the following format is used :
Declaration of a String in JAVA:
String var-name;
var-name = new String(“value”);
attention@computerscienceexpertise.com PDF created with pdfFactory Pro trial version www.pdffactory.com
String Functions
(v). equals();
in JAVA
FORMAT:
a1.equals(a2);
i). toLowerCase;
USAGE:
FORMAT:
This method gives ‘true’ if a1 string is equal to a2. a2=a1.toLowerCase;
(vi). length();
USAGE:
FORMAT:
This function/method converts all the
a1.length();
characters of the string in lowercase.
USAGE:
(ii). toUpperCase;
This function returns the length of characters
FORMAT:
present in the string.
a2=a1.toUpperCase;
(vii). ChartAt();
USAGE:
FORMAT:
This function/method is used to convert all
a1.ChartAt(n);
the characters of the string a1 into
USAGE:
uppercase.
This function/method returns nth character of the (iii). replace();
string a1.
FORMAT:
(viii). concat();
a2 = a1.replace(‘n’,’m’);
FORMAT:
USAGE:
a1.concat(a2);
This function replaces all the occurances of
Java Learning Made Easy
Comenzar desde el principio
