Chapter 1

Aus wiki
Wechseln zu: Navigation, Suche

Chapter 1

Objectives

Java Basics

  • Define the scope of variables
  • Define the structure of a Java class
  • Create executable Java applications, Run a Java program from command line
  • Import other Java packages
  • Compare and contrast features and components of Java

Working with Java Data Types

  • Declare and initialize variables
  • Difference between object reference variables and primitive variables
  • know how to read and write to object fields
  • explain an objects lifecycle

(creation, "dereference by reassignment", garbage collection)

  • develop code that uses wrapper classes

(Boolean, Double, Integer)

scopes

structure

Java classes have two primary elements: methods and fields.

  • fields/variables: hold a state of the program
  • methods: operate on the state

1 file = 1 class, if you have two classes, 1 must bi public an match the filename, other class can be private but not public too

classes are logical grouped into packages

if package starts with java or javax, this means it came with the JDK packages names are mostly letters and numbers separated by dots.

wildcards for matching all classes in the same package (not every class in the package is imported, the compiler figures out what's actually needed)

a wildcard only matches class names, not "fie.Files* -> import java.nio.*; not possbile only one wildcard is possible in an import-statement


package java.lang is automatically imported, you can type this package as an import statement, but you don't have to

default package, is a special unnamed package that you should use only for throwaway code

java looks in the current package for other classes.


compare and contrast features and components

declare and initialize variables

object variables vs. primitive variables

read and write object fields

object lifecycle

wrapper classes

imports

main method

String[] args, String args[], String ... args are all correct