Introduction to Java EE 518 Mathematics and Tools for Financial Engineering Goal Understand the activity of programming Design compile and run Java program Become familiar with OOP Software debugging and testing Topics Introduction tool setup Data types operators conditionals and loops Classes objects and methods Arrays and Array Lists Inheritance and Polymorphism Applications in Finance References Software JRE Java Runtime Environment JDK Java Development Kit Eclipse Integrated Development Environment Books Big Java by Cay S Horstmann Thinking in Java by Bruce Eckel The Java Tutorials by Oracle Introduction to Java Java Beginning What is Programming A computer must be programmed to perform tasks A computer program executes a sequence of basic operations W x y z Read location x Read location y Read location z Add x y and z Write to location w What is Programming X dw 5 Y dw 6 Z dw 7 W dw mov ax X add ax Y add ax Z mov W ax Programming Languages Easier to understand than machine codes C C C Visual C BASIC Java JavaScript JRuby MATLAB FORTRAN R PHP Perl Python Shell ASP JSP HTML XML XHTML Ten most popular programming languages are in descending order by overall popularity C Java PHP JavaScript C Python Shell Ruby Objective C and C Java Programming Language Most popular language Class based and object based Runs on a virtual machine JVM Simpler than C Successfully used to write Internet applets Has a very large library Java Programming Process Needs to be translated for the computer to understand it Example Program Classes are the fundamental building blocks of Java programs Every Java application contains a class with a main method Run Java Program Run Java Program Run Java Program Any Questions Introduction to Java Types Variables and Operators Types Every value in Java has a type boolean Truth value true or false int Integer 0 1 1 double Real number 1 1 3 14 String Text Create a Variable Type VarName Value Types int a 3 double a 3 a 3 a 3 0 int b 1 7 int b int 1 7 ERROR b 1 double c 2 3 c double c double 2 3 c Operators Assignment Addition Subtraction Multiplication Division Variables Checking Problem What do the following statements print System out println 3 4 System out println 3 4 System out println 3 4 Checking Problem What do the following statements print System out println 3 4 String 3 4 System out println 3 4 Integer 7 System out println 3 4 Integer String 34 Any Questions Introduction to Java Conditionals and Loops Any Questions Introduction to Java OOP Introduction Classes Objects Methods OOP Object Oriented Programming Objects are entities that manipulate by calling methods Method is a sequence of instructions that accesses the data of an object Class defines the data and methods that you can apply to its objects OOP Class Example represent a USC student in program Name Sex USC ID USC username Department Degree OOP Class Example represent a USC student in program String name boolean sex int uscid String username String department String degree OOP Class Why use classes Why not define directly String name1 boolean sex1 int uscid1 String username1 String department1 String degree1 OOP Class Define a student class OOP Creating Objects OOP Creating Objects OOP Creating Objects Constructor name Class name No return values Initialize the fields OOP Creating Objects OOP Methods Constructor and main are methods OOP Methods Adding Methods OOP Adding Methods Multiple Arguments MethodName Type1 Name1 Type2 Name2 Statements To Call MethodName argument1 argument2 Any Questions
View Full Document
Unlocking...