1 / 11

James Cain

Java. Java. James Cain. What about Java?. Its history Its data types and tools for manipulating data How it handles exceptions and events Swing – Java’s GUI Why it’s so dang popular Its less common uses. History of Java. Invented by James Gosling; designed in 1990 by Sun Microsystems

juan
Télécharger la présentation

James Cain

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. Java Java James Cain

  2. What about Java? • Its history • Its data types and tools for manipulating data • How it handles exceptions and events • Swing – Java’s GUI • Why it’s so dang popular • Its less common uses

  3. History of Java • Invented by James Gosling; designed in 1990 by Sun Microsystems • Originally named “Oak” • Named after the beverage Duke, the Java mascot

  4. The Data and its Manipulation For every integer from 1 to max, increasing... • Java supports 8 primitive data types: byte, short, int, long, float, double, boolean, and char • Implicit type conversion is used automatically • Type conversions are stricter than in C++ • Compound statements are easy to understand for(int i = 1; i <= max; i++) { ... } while(count < 20) { ... } if(AM) { ... } else if(PM) { ... } else { ... } While count is less than 20... If AM is true... Otherwise, if PM is true... Otherwise...

  5. Abstract Data public interface Function{double valueAt(double x);} public class F1 implements Function { ... } import java.awt.Graphics; • Java 5.0 supports generic types • Classes can be declared abstract • Interfaces encapsulate a basic idea for a class • Packages contain many class/interface definitions Must include valueAt method

  6. Exception Handling • Java includes predefined exceptions that are implicitly raised • All exception classes are descendants of Throwable Throwable Error Exception RuntimeException IOException

  7. The Swing of Things • Swing is a collection of classes and interfaces that include GUI components (widgets) • Text fields, radio buttons, checkboxes, drop-down menus, etc. • And, of course, images The function x2 + 2x

  8. Event Handling with Swing • Widgets “know” when something happens by using event listeners • Each listener is registered to a widget and a specific event public class Listener implements ItemListener { if(itemStateChanged( Checkbox1)) { ... } } What happens when Checkbox1 is clicked

  9. Java’s Popularity • Reliability – Trusted in many different areas • Portability – The Java Virtual Machine (JVM) brings the language to computers everywhere • Power – Java is flexible yet firm

  10. Other Uses for Java • Java applets – Gives new abilities to an XHTML document • Java Database Connectivity™ (JDBC) – Used to connect to a database and modify its data • Multithreading – Class with a method named run can execute in parallel

  11. Oh, and My Sources • Java: How to Program, 8th Edition – Paul and Harvey Deitel • http://docs.oracle.com/javase/tutorial/java/nutsandbolts/index.html> • Concepts of Programming Languages, 10th Edition – Robert W. Sebesta

More Related