== is used to check whether the references are of the same object.
.equals() is used to check whether the contents of the objects are the same.
But with respect to strings, object refernce with same content will refer to the same object.
String str1="Hello";
String str2="Hello";
(str1==str2) and str1.equals(str2) both will be true.
If you take the same example with Stringbuffer, the results would be different.
Stringbuffer str1="Hello";
Stringbuffer str2="Hello";
str1.equals(str2) will be true.
str1==str2 will be false.
No. String is not a Wrapper class.
Using length() method of String class.
An object is an instance of a class. Object reference is a pointer to the object. There can be many refernces to the same object.
trim() eliminate spaces from both the ends of a string.
The java.lang.Class class is used to represent the classes and interfaces that are loaded by a java program.
ArrayIndexOutOfBoundsException.
Object's of String class is immutable and object's of Stringbuffer class is mutable moreover stringbuffer is faster in concatenation.
Math class provide methods for mathametical functions.
No. It cannot be instantited. The class is final and its constructor is private. But all the methods are static, so we can use them without instantiating the Math class.
It simply returns the absolute value of the value supplied to the method, i.e. gives you the same value. If you supply negative value it simply removes the sign.
This method returns always double, which is not less than the supplied value. It returns next available whole number
This method returns always double, which is not greater than the supplied value.
The max() method returns greater value out of the supplied values.
The min() method returns smaller value out of the supplied values.
The random() method returns random number between 0.0 and 1.0. It always returns double.