JerZyNoVa
2015-02-24 07:28:52 UTC
For Example:
public class HbdMom
{
public static void main(String[] args)
{
final String MSG1 = "********************";
final String MSG2 = "***Happy Birthday***";
final String MSG3 = "******* Mom! *******";
final String MSG4 = "********************";
System.out.println(MSG1);
System.out.println(MSG2);
System.out.println(MSG3);
System.out.println(MSG4);
}
}
Nothing is imported.
But for:
import java.util.Scanner;
public class Plp02A
{
public static void main(String[] args)
{
int i = 0;
int[] lab02aArray = { 87, 101, 108, 99, 111, 109, 101, 32, 44, 32, 116, 111, 32, 67, 83, 67, 32, 49, 48, 49, 33 };
Scanner strIn = new Scanner(System.in);
System.out.print("Please type your name...");
String stdName = strIn.nextLine();
System.out.println("\n\n");
for (i = 0; i < 8; i++)
System.out.print((char)lab02aArray[i]);
System.out.print(stdName);
for ( ; i < 20; i++)
System.out.print((char)lab02aArray[i]);
System.out.print((char)lab02aArray[i] + "\n\n");
System.out.println("**** end of Lab02a ****");
} // end of main method
} // end of class Lab02a
java.util.Scanner is imported.
*Please keep in mind this is all new to me, as I just began taking classes in Java this semester.
I'm just wondering when would you would need to import something when writing a java program.