Love cunts

Classified in Computers

Written at on English with a size of 3.98 KB.

 

Commandline

Compile single file: javac x.Java

Compile multiple files: javac *.Java

Running single file: java x

Pseudocode

     symbol represents a For loop

a <-- b="" -="" b="" 'gets'="" the="" value="" of="">-->

Variables 

ModifierClassPackageSubclassWorld

public

Y

Y

Y

Y

protected

Y

Y

Y

N

no modifier (default)

Y

Y

N

N

private

Y

N

N

N

'Static' Variables:

  • belongs to class, not object
  • initialised only once
  • single copy shared by instances of the class
  • can be accessed directly by class name

Final Variables:

  • Only defined once
  • Never overwritten

Local Variables:

  • Only valid within their scope (the loop)
  • Cannot be 'public'

Object Type

  • An object has both static and dynamic types
  • Static, on the left, doesn't change
  • Dynamic, on the right, can change
  • Static type must be a supertype of the dynamic type
  • Dynamic type determines what code is executed and how the object is constructed at run time

'Static' Methods

  • belongs to class, not object

  • can only use static data/methods

  • can be accessed directly by class name

Operators

OperatorEquivelant
a += ba = a + b
a -= ba = a - b
a *= ba = a * b
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Exceptions

try {

    do things

} catch (exception e) {

    handle exception

}

Entradas relacionadas: