Answer:
No. Once a String has been created you cannot change its
data. (Although you can create a new String that is an altered
version of the original.)
Packages
A group of related classes is often put into a collection
called a package.
Many packages come standard with Java.
For example, the String class is part of the
package called java.lang.
Several useful classes are part of that package.
You can use the classes in this package without doing anything special.
Other standard packages also come with Java.
To use a class from one of these packages your program must
tell the compiler what package contains the class.
One way to do this is to use the package name with the class.
Here is a program that explicitly mentions where the String class
is found:
class ImportDemo01
{
public static void main ( String[] args )
{
java.lang.String str;
int len;
str = new java.lang.String( "Elementary, my dear Watson!" );
len = str.length();
System.out.println("The length is: " + len );
}
}
This program runs the same as its previous version.
Unlike most packages, the explicit mention of the package
java.lang
is not needed.
QUESTION 15:
The class Scanner is not part of the java.lang package.
Does a program that creates a Scanner object need to tell the compiler
where that class can be found?