Download presentation
Presentation is loading. Please wait.
Published byAmbrose Quinn Modified over 8 years ago
1
Java Spring 2010
2
PImage Let’s look at the PImage class in ProcessingPImage –What are the fields (i.e., variables)? –What methods are available? –What about the constructor---how many parameters does it have? There are 4 constructors each with a different number of parameters
3
PImage Revisited Here’s an alternative way of looking at the documentation for PImagePImage This documentation is produced by Javadoc Javadoc Processing is implemented as a set of Java classes that accompany those normally provided with Java Can you find the line() method?
4
Java Java is a programming language developed by Sun Microsystems in 1995. Java is one of the first languages to be platform independent. –Java is compiled to byte-code that runs on a Java interpreter A Java program never executes directly (i.e., natively) on a machine; instead the Java interpreter reads the byte code and executes the corresponding native machine instructions. To run Java programs on a computer, all that is needed is the interpreter (java virtual machine) and some library routines (the API)
5
Ways to run Java Java is rarely run as an “application” –Such as for forecasting weather Applet –Runs within a browser window –Superclass of Processing PApplet Web application –Runs on a web server Javascript is not Java
6
The Java API The Java API is the code that comes with the java interpreter (a.k.a. the java virtual machine) when you download java. The java API is a collection of Java classes---take a look at the API for Java 6 (aka 1.6)API for Java 6 (aka 1.6) See if you can find the String class.
7
Running Java outside of Processing If the instructor is so inclined, you’ll be show how to run the following exciting Java application under a Java IDE Otherwise, you’ll just look at the code. (Or maybe not even that.)
8
Pets public class Pets { /* Creates a Cat and a Dog */ public static void main (String [] args) { Cat tom = new Cat (); // create Cat object Dog spike = new Dog; // create Dog object // demonstrate Cat behavior tom.bite (spike); System.out.println (); // Skip a line of output // demonstrate Dog behavior spike.beenBittenBy (tom); }
9
The cat public class Cat { public void hiss () { System.out.println ("Hiss!"); } public void scratch (Dog victum) { System.out.println ("I'm scratching the dog"); victum.growl (); } public void bite (Dog sillyDog) { System.out.println ("I'm bitting the dog"); sillyDog.yelp (); scratch (sillyDog); }
10
The Dog public class Dog { public void bark () { System.out.println ("Arf!"); } public void growl () { System.out.println ("Grrrr!"); } public void yelp () { System.out.println ("Awooo!"); } public void beenBittenBy (Cat sillyCat) { System.out.println("I've been bitten by a cat with a mean hiss:"); sillyCat.hiss (); }
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.