1 / 6

SEEM3460 Tutorial

SEEM3460 Tutorial. Java Programming in Unix. Code Translation. Java source code. machine code for target machine 1. Bytecode interpreter. Java compiler. Java bytecode. machine code for target machine 2. Bytecode interpreter. Compilation and Execution. Compilation:

Download Presentation

SEEM3460 Tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SEEM3460 Tutorial Java Programming in Unix

  2. Code Translation Java source code machine code for target machine 1 Bytecode interpreter Java compiler Java bytecode machine code for target machine 2 Bytecode interpreter

  3. Compilation and Execution • Compilation: • command > javac Gasmileage.java • generates bytecode: Gasmileage.class • Execution: • command > java Gasmileage • load bytecode: Gasmileage.class • call main of class Gasmileage

  4. Structure of A Java Program // comments about the class public class MyProgram class header { } // comments about the method public static void main (String[] args) class body { } method header method body

  5. New Concepts in Java • Code – create a class Holder with main • Class – create a class Coin • Constructor – create method Coin • Methods – create method Coin.flip • Property – during flip, generate random Head=1;Tail=0 as Coin.value(import java.util.Random, nextInt/nextFloat) • Encapsulation – during flip, generate random orientation 0~360 (float) as private variable Coin.orientation • Casting – return integer value of Coin.orientation as read-only property

  6. Flip a Coin Coin value and orientation Holder

More Related