Bài giảng Introduction to Java Programming - Hoàng Văn Hậu

Course Objectives

Upon completing the course, you will understand

Create, compile, and run Java programs

Primitive data types

Java control flow

Methods

Arrays (for teaching Java in two semesters, this could be the end)

Object-oriented programming

Core Java classes (Swing, exception, internationalization, multithreading, multimedia, I/O, networking, Java Collections Framework)

Course Objectives, cont.

You will be able to

Develop programs using Eclipse IDE

Write simple programs using primitive data types, control statements, methods, and arrays.

Create and use methods

Write interesting projects

 

ppt35 trang | Chia sẻ: hienduc166 | Lượt xem: 448 | Lượt tải: 0download
Bạn đang xem trước 20 trang tài liệu Bài giảng Introduction to Java Programming - Hoàng Văn Hậu, để xem tài liệu hoàn chỉnh bạn click vào nút TẢI VỀ ở trên
Introduction toJava ProgrammingY. Daniel LiangEdited by Hoàng Văn Hậu – VTC Academy – THSoft co.,ltdhttps://play.google.com/store/apps/developer?id=THSoft+Co.,LtdIntroductionCourse ObjectivesOrganization of the BookVTC Academy2THSoft Co.,LtdCourse ObjectivesUpon completing the course, you will understand Create, compile, and run Java programsPrimitive data typesJava control flowMethodsArrays (for teaching Java in two semesters, this could be the end)Object-oriented programmingCore Java classes (Swing, exception, internationalization, multithreading, multimedia, I/O, networking, Java Collections Framework)VTC Academy3THSoft Co.,LtdCourse Objectives, cont.You will be able to Develop programs using Eclipse IDEWrite simple programs using primitive data types, control statements, methods, and arrays.Create and use methodsWrite interesting projectsVTC Academy4THSoft Co.,LtdSession 01 Introduction to Java and EclipseWhat Is Java?Getting Started With Java ProgrammingCreate, Compile and Running a Java ApplicationVTC Academy5THSoft Co.,LtdWhat Is Java?Java language programming marketVTC Academy6THSoft Co.,LtdHistoryJames Gosling and Sun MicrosystemsOakJava, May 20, 1995, Sun WorldHotJava The first Java-enabled Web browserJDK EvolutionsJ2SE, J2ME, and J2EE (not mentioned in the book, but could discuss here optionally)VTC Academy7THSoft Co.,LtdCharacteristics of JavaJava is simpleJava is object-orientedJava is distributedJava is interpretedJava is robustJava is secureJava is architecture-neutralJava is portableJava’s performanceJava is multithreadedJava is dynamicVTC Academy8THSoft Co.,LtdJava IDE ToolsForte by Sun MicroSystems Borland JBuilderMicrosoft Visual J++NetBean by OracleIBM Visual Age for JavaEclipse by Sun MicroSystems VTC Academy9THSoft Co.,LtdGetting Started with Java ProgrammingA Simple Java ApplicationCompiling ProgramsExecuting ApplicationsVTC Academy10THSoft Co.,LtdA Simple ApplicationExample 1.1//This application program prints Welcome//to Java! package chapter1;public class Welcome {	 public static void main(String[] args) { System.out.println("Welcome to Java!"); }}RunSourceNOTE: To run the program, install slide files on hard disk.VTC Academy11THSoft Co.,LtdCreating and Compiling ProgramsOn command linejavac file.javaVTC Academy12THSoft Co.,LtdExecuting ApplicationsOn command linejava classnameVTC Academy13THSoft Co.,LtdExamplejavac Welcome.javajava Welcomeoutput:...VTC Academy14THSoft Co.,LtdCompiling and Running a ProgramWhere are the files stored in the directory?VTC Academy15THSoft Co.,LtdAnatomy of a Java ProgramCommentsPackageKeywordsVariables – Data typeOperatorsControl flowIf else statementVTC Academy16THSoft Co.,LtdCommentsEclipse shortcut key:Ctrl + Shift + CCtrl + Shift + /Ctrl + /VTC Academy17THSoft Co.,LtdPackageVTC Academy18THSoft Co.,LtdKeywords (reserved words)	 Academy19THSoft Co.,LtdBlocksA pair of braces in a program forms a block that groups components of a program. VTC Academy20THSoft Co.,LtdData Typesbyte 8 bitsshort 16 bitsint 32 bitslong 64 bitsfloat 32 bitsdouble 64 bitschar	 16 bits	VTC Academy21THSoft Co.,LtdConstantsfinal datatype CONSTANTNAME = VALUE; final double PI = 3.14159; final int SIZE = 3;VTC Academy22THSoft Co.,LtdOperators+, -, *, /, %, ++, --, +=, -=, *=, /=, ^, &, |5/2 yields an integer 2.5.0/2 yields a double value 2.55 % 2 yields 1 (the remainder of the division) VTC Academy23THSoft Co.,LtdArithmetic Expressionsis translated to(3+4*x)/5 – 10*(y-5)*(a+b+c)/x + 9*(4/x + (9+x)/y)VTC Academy24THSoft Co.,LtdShortcut Assignment OperatorsOperator	Example	Equivalent+=	i+=8	i = i+8-=	f-=8.0	f = f-8.0*=	i*=8	i = i*8/=	i/=8	i = i/8%=	i%=8	i = i%8VTC Academy25THSoft Co.,LtdIncrement andDecrement OperatorsVTC Academy26THSoft Co.,LtdIncrement andDecrement Operators, cont.VTC Academy27THSoft Co.,LtdVariables// Compute the first arearadius = 1.0;area = radius*radius*3.14159;System.out.println("The area is “ + area + " for radius "+radius);// Compute the second arearadius = 2.0;area = radius*radius*3.14159;System.out.println("The area is “ + area + " for radius "+radius);VTC Academy28THSoft Co.,LtdDeclaring Variablesint x; // Declare x to be an // integer variable;double radius; // Declare radius to // be a double variable;char a; // Declare a to be a // character variable;VTC Academy29THSoft Co.,Ltdif ... ElseVTC Academy30THSoft Co.,LtdDisplaying Text in a Message Dialog Boxyou can use the showMessageDialog method in the JOptionPane class. JOptionPane is one of the many predefined classes in the Java system, which can be reused rather than “reinventing the wheel.” RunSourceVTC Academy31THSoft Co.,LtdActions on EclipseDevelopment environmentCopy folder: Java_setup_thsoftInstall JDKJAVA_HOME=path_to_jreInstall Eclipse (copy folder only)Create workspaceCreate simple projectVTC Academy32THSoft Co.,LtdActions on EclipseCreate, build, run welcome.java and welcomeBox.javaRewrite demoCalcule this expression with a = b = c = 2.5; x = y = z = 8.7VTC Academy33THSoft Co.,LtdActions on EclipseProblem ax + b = 0Problem ax^2 + bx + c = 0Input data by user. (JOptionPane)VTC Academy34THSoft Co.,LtdAction on classTeacher hauc2@yahoo.com0984380003https://play.google.com/store/search?q=thsoft+co&c=appsCaptionsMembersVTC Academy35THSoft Co.,Ltd

File đính kèm:

  • pptjava co ban.ppt