Lecture 2A
  Basic Elements
  Statements
  Comments
  Javadoc
 
Expressions
  Primitive Types

  MorePrimitives
  Floating Point
  Casts & Mixing
  Math Tools
  Basic Graphics
  Drawing Methods

Lectures

1A: Introduction
1B: Java Intro
2A: BuildingBlocks
2B: Objects
3A: More Objects
3B: Exceptions
       & Threads
4A: Waves
4B: Nuclear &
       Particle
5A: AWT
5B: More AWT
      & Graphics
6A:Detectors &
      Simulation
6B: LHC/Atlas &
     RandomSims    
7A: Swing
7B: Java2D
8A: Java Apps
8B: Dialogs &
    MoreClasses
9A: Java I/O
9B: Utilities,
        Unicode
10A: More
    Threading
10B: File
    Handling
11A: Array,Print,
    Images
11B: SimplePhysics
    Simulation
12A: Tips &
    Techniques
12B: More Tips &
    Techniques
13A: Satellite
    
Simulations
13B: Intro to Java
    Networking
14A: Java Servers
14B: HTTP Server
15A: ServerClient
15B: ServerClient
   Expt.Simulation
16A: Course
          Review
16B: ExerciseTest
        Discussion

    Contacts
    Description
    Exercises
    Index
    Outline
    Q&A
    Resources
    StudentInfoForm
    Student Pages
    What's New

 

Home : Lectures : Lecture 2A: Java Elements
The Basic Elements of Java

The basic elements of Java include:

  • Keywords - words reserved for Java:
         
    class, float, return, etc.

  • Primitive types - specifies how values are stored in memory and what operations they can undergo:

          
    int, float, boolean, etc


  • Operators: +,-,/,*, etc.

  • Declarations - allocate memory for an instance of a particular type:
            
    int x; double y=1.0; etc.

  • Literals - immediate values :
            int i = 3; <= 3 is a literal
            double x = 3.0; <= 3.0 is a literal


  • Statements - express an action to execute:
        
    x=5;
        if( y<5) x= 3;
        etc.


  • Classes - provide the data structure and operations for a new type. Objects are instances of a class.

Note that Java syntax has much in common with C/C++.

However, there are many small, as well as not so small, differences.

 

Home Lectures Resources Index Contacts Students


Physics Simulations with JavaTM
KTH, Kurskod: 5A1418
Curator: Clark S. Lindsey