DOC PREVIEW
USC EE 518 - Java Lecure 1 Introduction, Syntax, and OOP Beginning

This preview shows page 1-2-3-4-26-27-28-53-54-55-56 out of 56 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Java Lecture 1.pdf页面提取自- Java 2.pdfIntroduction to Java EE 518: Mathematics and Tools for Financial EngineeringGoal • Understand the activity of programming • Design, compile and run Java program • Become familiar with OOP • Software debugging and testingTopics • Introduction, tool setup • Data types, operators, conditionals, and loops • Classes, objects, and methods • Arrays and Array Lists • Inheritance and Polymorphism • Applications in FinanceReferences • 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 OracleIntroduction to Java Java BeginningWhat 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 wWhat is Programming? • X dw 5 • Y dw 6 • Z dw 7 • W dw ? • mov ax,X • add ax,Y • add ax,Z • mov W,axProgramming 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 libraryJava Programming Process • Needs to be translated for the computer to understand itExample Program • Classes are the fundamental building blocks of Java programs • Every Java application contains a class with a main methodRun Java ProgramRun Java ProgramRun Java ProgramAny Questions?Introduction to Java Types, Variables, and OperatorsTypes • 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 = ValueTypes • int a = 3; // a = 3 • double a = 3; // a = 3.0 • int b = 1.7; // ERROR • int b = (int)1.7; // b = 1 • double c = 2/3; // c = ? • double c = (double)2/3; // c = ?Operators • Assignment: = • Addition: + • Subtraction: - • Multiplication: * • Division: /VariablesChecking 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 – 34Any Questions?Introduction to Java Conditionals and LoopsAny Questions?Introduction to Java OOP Introduction Classes, Objects, MethodsOOP • 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 objectsOOP - 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 degree1OOP - Class • Define a student classOOP – Creating ObjectsOOP – Creating ObjectsOOP – Creating Objects • Constructor name = Class name • No return values • Initialize the fieldsOOP – Creating ObjectsOOP - Methods • Constructor and main are methodsOOP - Methods • Adding MethodsOOP – Adding Methods • Multiple Arguments • […] MethodName (Type1 Name1, Type2 Name2, …){ Statements } • To Call: • MethodName(argument1, argument2)Any


View Full Document

USC EE 518 - Java Lecure 1 Introduction, Syntax, and OOP Beginning

Download Java Lecure 1 Introduction, Syntax, and OOP Beginning
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Java Lecure 1 Introduction, Syntax, and OOP Beginning and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Java Lecure 1 Introduction, Syntax, and OOP Beginning 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?