Java-Intro-Spr04 - Introduction to Java COP 3330...

Info icon This preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to Java COP 3330 Introduction to OO Programming with Java © Dr. David A. Workman School of CS University of Central Florida January 2004
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
January 2004 (c) Dr. David A. Workman 2 References Object Oriented Software Development Using Java by Xiaoping Jia, Addison-Wesley, 2000; ISBN = 0-201-35084-X Web Sites http://java.sun.com/docs/books/jls/index.html http://java.sun.com/
Image of page 2
January 2004 (c) Dr. David A. Workman 3 Getting Started The Java Environment Java Object (bytecode) Files Java Compiler (javac) unit-name .java > javac unit-name.java > java main-unit [commandline args] Java Interpreter (java) unit-name .class program input files program output files Java Source Files network Java Interpreter (java) Remote Java enabled browser application applet > setenv CLASSPATH newjavadir :$CLASSPATH > echo $CLASSPATH See notes applet See Notes
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
January 2004 (c) Dr. David A. Workman 4 Program Building Blocks Classes Classes are the primary building blocks of Java programs (applications & applets) - everything in Java is an instance of some class, including programs - Applications are Java programs that can be compiled and run like any other program in the host OS environment - they have normal access to all host computer resources . Applets, on the other hand, are programs callable from an HTML page , transportable across networks, and executable by a Java-enabled browser; they have restricted access (based on permissions) to the host environment. Interfaces Are similar to class interfaces in C++, but have important differences; interfaces encapsulate a collection of constants and method declarations that are implemented by one or more other classes ; interfaces define and standardize a collection of capabilities shared by all classes that implement the interface. Packages Packages provide a way to group classes, interfaces, and other packages under a single name; package names are identical to the name of the directory in which components of the package are stored in the host file system . Import statements are used in source files to give direct visibility to package components.
Image of page 4
January 2004 (c) Dr. David A. Workman 5 Program Structure Java Standard Java Library CLASSPATH Libraries Current Directory (default package) Other (Nested) Packages Classes Interfaces 1..* * * Classes * Fields Methods 1..* 1..* File Interface Class (public | pkg) Class (private) * mutually exclusive 1..*
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
January 2004 (c) Dr. David A. Workman 6 Java Application public class Hello { //the first letter of a class name is upper case, by convention public static void main( String[] args ){ //must be declared like this String user = args[0]; // System is a standard Java class // System.out is a predefined PrintStream object denoting the CRT System.out.println("Hello " + user + '!'); // "+" is concatenation System.out.println("I see you have succeeded in entering the \"Matrix\"!"); }// main method }//Hello Hello.java Escape character is used to embed double-quotes in a string.
Image of page 6
January 2004 (c) Dr. David A. Workman 7 Things to Remember Java programs are organized as a hierarchical collection of “ package units ( a “Tree” of packages ).
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern