Final- Java Basics ppt Flashcards
Sample program
public class NameWithSameNameAsFile {
public static void main (String[] args)
{
System.out.println(“Happy Thanksgiving!”);
} //end main
} //end class
data types (5)
int, double, boolean, char, String
int
whole numbers
double
numbers with a decimal point
boolean
true or false
char
use ‘ ‘ to enclose a single character
String
Not a primitive type, notice the capital S. Use “ “
For naming, the first character can be
a letter, underscore, or $
Subsequent characters may be
letters, numbers, underscores, or $
variable names cannot be
keywords
Are names case-sensitive?
yes.
constant names should be
ALLCAPS
variable names
shouldBeLikeThis
Variables and constants will be declared
at the beginning of the method.
Variable and constant declaration looks like this:
final int MAX_HOURS = 18; String name; int age; double gradePointAvg; char status; boolean active;