Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Huazhong University of Science and Technology JAVA Programming Language Lecture 1:Introduction Jing XU School of Electronic Information and Communications Huazhong University of Science and Technology Huazhong University of Science and Technology Instructor How to contact me? Email: [email protected] Web: http://itec.hust.edu.cn/~xujing Jing XU Course Computer Network C Programming Language Java Programming Language Research (@ITEC) Wireless Networks, such as CRNs, WMNs, … Human Behavior on Internet Programming C, C++, Java, Linux/Unix Programming, … Java Programming Language 2 Huazhong University of Science and Technology Lecture 1 Introduction of this course Why? Goals Textbook Course Schedule Chapter 1 Java History What is Java? Java Nowadays Quick view to Java Applications Java Programming Language 3 Huazhong University of Science and Technology Why we need Java Language? Java has dominated over 20% quotient of the computer language market. http://spectrum.ieee.org/computing/software/top-10-programming-languages http://redmonk.com/sogrady/2015/01/14/language-rankings-1-15/ Java Programming Language 4 Huazhong University of Science and Technology What is programming What is programming? The process of designing, writing, testing, debugging / troubleshooting, and maintaining the source code of computer programs. What is programming language? This source code is written in a programming language The purpose of programming is to create a program that exhibits a certain desired behavior Java and C/C++ are the most two widely supported programming language Java Programming Language -5- Huazhong University of Science and Technology Goals of this course Understanding the fundamental programming concepts on Java Programming, Data types, Controls, methods (i.e. functions), … Understand the idea of object-oriented software design, can do simple design Class, Object, Inheritance, … Understand the advanced application of JAVA Thread, I/O, socket programming, … Java Programming Language 6 Huazhong University of Science and Technology Reference textbooks [1] H.M.Deitel, P.J.Deitel, Java How to Program, 8th , Pearson 2012. [2] Y.Daniel Liang, Prentice Hall, Introduction to Java Programming(brief version), Pearson 2011. [3] Cay S. Horstmann, Prentice Hall, Core Java 2 (Vol.1) & (Vol. 2), Prentice Hall,2004. [4] Bruce Eckel, MindView Inc, Thinking in Java, 3rd, President, MindView, Inc,2003. Java Programming Language 7 Huazhong University of Science and Technology Course Schedule An introduction to Java Variable and data type Operators and control statement Basic Object-Oriented programming concept Inheritance Polymorphism Java Exception handling Java database access Java Programming Language 8 Huazhong University of Science and Technology Evaluation and requirements Evaluation Criterion Attendance check (20%) Programming assignments (40%) Final Examination (40%) Requirements Lecturing: English Programming ability Final Paper Test Java Programming Language 9 Huazhong University of Science and Technology Tips and suggestions More work should be done after lecture hours. 1. First of all, practice in programming 2. Read textbook before/after lecture 3. Read other English reference textbooks Java Programming Language -10- Huazhong University of Science and Technology CONCEPTS IN JAVA Java Programming Language 11 Huazhong University of Science and Technology Concepts in Java Java JDK: Java Development Kit Java development core part, including JRE, Java tool set and Java class library J2EE, J2SE, J2ME (from Java 1.5, currently 1.8) JRE: Java Runtime Environment A simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high-performance, multi-threaded, and dynamic language (from Java whitepaper) All the programs must be executed in JRE JVM, Java core class library, and supported files JVM: Java Virtual Machine A part of JRE An virtual computer generated by Java platform, it has its own hardware arch, such as the processor, stacks, registers etc, even the instruction systems Translate the bytecode to the CPU instructions or system functions Java Programming Language 12 Huazhong University of Science and Technology What is Java? Fully support O-O Programming Small, simple and portable Java was designed to be small, simple, and portable across platforms and operating systems Java is not only a kind of programming language, but also a software programming running environment or platform Java Programming Language 13 Huazhong University of Science and Technology J2EE, J2SE and J2ME Java Programming Language 14 Huazhong University of Science and Technology Java, J2SE, JDK & JRE Java Programming Language 15 Huazhong University of Science and Technology Who develops Java? The Java language was developed at Sun Microsystems in 1991 as part of a research project to develop software for consumer electronics devices. Java is a programming language and environment whose original name was Oak and developed as a part of the Green project at Sun started by James Gosling. Java Programming Language 16 Huazhong University of Science and Technology Java’s initial goal Java’s goals at that time were to be small, fast, efficient, and easily portable to a wide range of hardware devices. It is those same goals that made Java an ideal language for distributing executable programs via the World Wide Web. “Write once, run anywhere!” http://www.oracle.com/technetwork/java/javase/overview/javahistory-index-198355.html http://oracle.com.edgesuite.net/timeline/java/ Java Programming Language 17 Huazhong University of Science and Technology Java history 1991 1992 Java is open sourced 2007 Technology that change our daily lives 2006 The world takes Notice 2000 An Innovation before its time 1995 Exploring green fields in consumer electronics Making rich internet application easier to build (JavaFX) 2014 A new version of JDK with great changes Java Programming Language 18 Huazhong University of Science and Technology Java’s application nowadays Enterprise information system Mobile application Distributed computing Web services Grid Java Programming Language 19 Huazhong University of Science and Technology The Types of Java Programs Java Application Run on local computer Based on J2SE Java Applet Run Java Servlet Run on web browser on application server JavaBeans Cannot run independently Enterprise JavaBeans Run on application server Based on J2EE Java Programming Language 20 Huazhong University of Science and Technology Java’s Features Simple Object-Oriented language Distributed Robust Secure Architecture-Neutral Multithread Dynamic Java Programming Language 21 Huazhong University of Science and Technology QUICK VIEW TO JAVA APPLICATION Java Programming Language 22 Huazhong University of Science and Technology Quick View to Java Application 1 // Sample 01: Welcome1.java 2 // Text-printing program. 3 4 public class Welcome1 { 5 6 // main method begins execution of Java application 7 public static void main( String[] args ) 8 { 9 System.out.println( "Welcome to Java Programming!" ); 10 11 } // end method main 12 13} // end class Welcome01 Output: Welcome to Java Programming! Java Programming Language 23 Huazhong University of Science and Technology Quick View to Java Application Output: Welcome to Java Programming! Java Programming Language 24 Huazhong University of Science and Technology Quick View to Java Application 1 // Sample 01: Welcome1.java Comments start with: // Comments ignored during program execution Document and describe code Provides code readability Traditional comments: /* ... */ /* This is a traditional comment. It can be split over many lines */ 2 // Text-printing program. Another line of comments Note: line numbers not part of program, added for reference Java Programming Language 25 Huazhong University of Science and Technology Quick View to Java Application 3 Blank line Makes program more readable Blank lines, spaces, and tabs are Ignored by compiler 4 white-space characters public class Welcome01 { Begins class declaration for class Welcome01 Every Java program has at least one user-defined Keyword: words reserved for use by Java class keyword followed by class name Naming classes: capitalize every word SampleClassName, UndergraduateStudent, … Java Programming Language class 26 Huazhong University of Science and Technology Quick View to Java Application 4 public class Welcome01 { Name of class called identifier Series of characters consisting of letters, digits, underscores ( _ ) and dollar signs ( $ ) Does not begin with a digit, has no spaces Examples: Welcome1, $value, _value, button7 7button is invalid Java is case sensitive (capitalization matters) a1 and A1 are different Java Programming Language 27 Huazhong University of Science and Technology Quick View to Java Application 4 public class Welcome01 { Left brace { Begins body of every class Right brace ends declarations (line 13) 7 public static void main( String args[] ) Part of every Java application Applications begin executing at main Parenthesis indicate main is a method Java applications contain one or more methods Java Programming Language 28 Huazhong University of Science and Technology Quick View to Java Application 7 public static void main( String args[] ) Exactly one method must be called main Methods can perform tasks and return information void means main returns no information 8 { Left brace begins body of method declaration Ended by right brace } (line 11) Java Programming Language 29 Huazhong University of Science and Technology Quick View to Java Application 9 System.out.println( "Welcome to Java Programming!" ); Instructs computer to perform an action Prints string of characters String - series characters inside double quotes White-spaces in strings are not ignored by System.out compiler Standard output object Print to command window (i.e., MS-DOS prompt) Method System.out.println Displays line of text Argument inside parenthesis This line known as a statement Statements must end with semicolon ; Java Programming Language 30 Huazhong University of Science and Technology Quick View to Java Application 11 } // end method main Ends method declaration 13 } // end class Welcome01 Ends class declaration Can add comments to keep track of ending braces Comments can start on same line after code Remember, compiler ignores comments Java Programming Language 31 Huazhong University of Science and Technology Quick View to Java Application Saving files name must be class name with .java extension Welcome1.java File Compiling a program Open a command prompt window, go to directory where program is stored Type javac Welcome1.java If no errors, Welcome1.class created Has bytecodes that represent application Bytecodes passed to Java interpreter Java Programming Language 32 Huazhong University of Science and Technology Quick View to Java Application Executing a program on CMD model Type java Welcome01 Interpreter loads .class file for class Welcome1 .class extension omitted from command Interpreter calls method main Executing Welcome1 in a Microsoft Windows Command Prompt. Java Programming Language 33 Huazhong University of Science and Technology A modified Welcome01 sample Java Programming Language 34 Huazhong University of Science and Technology Thanks! Jing XU ITEC, EIC, HUST Email: [email protected] Website: http://itec.hust.edu.cn/~xujing Huazhong University of Science and Technology Platform-independent Other Language Java Platform Java Programming Language 36