JavaBasics1

Java Basics 1.03

Operators

  • follows C standards

 

Types

  • Assignment
  • Equality or relational
  • Mathematical
  • Conditiona
  • Ternary (short-hand conditional)

 

Assignment and Math Operators

=, +, -, *, /, %

 

Incrementing

intValue = 10;

intValue ++; // 11

Java Basics 1.02

Numeric are Primitives

  • Simple value
  • Stored in fastest memory
  • Numeric/Boolean
  • all lowercase
  • int varprimitive

 

Type

Bits

Java Basics 1.01

Main Class

public static void main(String[] args) {

 

Required by Class:

  • public - can be called anywhere
  • static - no instance required to run
  • void - nothing returned by class
  • String[] args
    • [] - an array
    • args - default variable to hold passed data
    • Passed by Java’s JVM

 

 

Java: Javadoc: How to Write Doc Comments for the Javadoc Tool

Sample Comment/Method

/**
* Returns an Image object that can then be painted on the screen.
* The url argument must specify an absolute {@link URL}. The name
* argument is a specifier that is relative to the url argument.
* <p>
* This method always returns immediately, whether or not the
* image exists. When this applet attempts to draw the image on
* the screen, the data will be loaded.

Java: Enum Types

An enum type is a special data type that enables for a variable to be a set of predefined constants. The variable must be equal to one of the values that have been predefined for it. Common examples include compass directions (values of NORTH, SOUTH, EAST, and WEST) and the days of the week.

Because they are constants, the names of an enum type's fields are in uppercase letters.

In the Java programming language, you define an enum type by using the enum keyword. For example, you would specify a days-of-the-week enum type as:

Subscribe to JavaBasics1