GIÁO TRÌNH JAVA cơ bản
... thực chất là chạy các Applet Java tr ên Web. Mã nguồn Java Trình biên dịch Java Trình thông dịch Java Máy cụ thể, không phụ thuộc hệ thống Tập mã nhị phân Java Máy ảo Java TRUNG TÂM ĐÀO T ẠO TRỰC ... có chứa “máy ảo Java”. Máy ảo Java l à một tập các quy ước về chỉ thị, dạng thức l ưu trữ, thanh ghi v.v như máy tính th ực sự và trình thông dịch Java tạo ra máy ảo Java này. Trình thông dịch ... Microsoft th ấy được tính ưu việt của Java nên đã bắt tay xây dựng môi trình lập trình cho ngôn ngữ này. Sau khi đã mua bản quyền, Microsoft đ ã tung ra công cụ lập trình Java có tên J ++ và đến nay đã
Ngày tải lên: 03/02/2015, 09:21
Giáo trình Java cơ bản 01
... programming using the Java language To gain experience in engineering reliable programs Trang 5… in particular OOJ/OJA and IPJ/IJA have been designed to form the core of Java programming They ... Trang 1Welcome to Object-Oriented Programming Using Java Trang 3► Subject Information Trang 41/4 Subject aims To understand how computers work ... IPJ/IJA have been designed to form the core of Java programming They provide a solid foundation for Java application development Trang 61/6 Teaching philosophy Learning is an active process The
Ngày tải lên: 24/03/2016, 22:01
Giáo trình Java cơ bản 02
... Trang 35Running Java programs Java compilation process Java execution process – Java byte code is read and executed via a Java byte code interpreter Program written in Java Java byte code ... run Java programs in Unix To create a file > vi <filename> Note: to create a Java program the filename must end in java To compile a program > javac <filename>.java ... Intermediate code compiler javac Trang 36Byte code and JVM The javac command converts the source programs into byte code Byte code files are those with the extension .class The java command causes
Ngày tải lên: 24/03/2016, 22:03
Giáo trình Java cơ bản 04
... Create and test the program Use vi to edit the program > vi Party.java Compile the program > javac Party.java Run the program > java Party 4/26 Results of tests Please enter the number of guests: ... and test the program Use vi to edit the program > vi Party .java Compile the program > javac Party .java Run the program > java Party 4/26 Results of tests Please enter the number of ... 4/13 Execution staring point in Java Java programs are a collection of classes Each class must be stored in a file with the same name, but also with the java extension A class may have
Ngày tải lên: 24/03/2016, 22:05
Giáo trình Java cơ bản 07
... an initial capital shoeSize – This convention is sometimes referred to as camelBack notation Java is case sensitive, therefore it distinguishes between uppercase and Trang 8Keywords Keywords ... floating-point Trang 12Integer data types positive and negative values) 4 types of integers in Java that store values in different amounts of memory range of values they can store specific ... Floating-point number types store numbers with fractional parts 2 types of floating-point numbers in Java that store values in different amounts of memory Not all numbers can be stored exactly using
Ngày tải lên: 24/03/2016, 22:07
Giáo trình Java cơ bản 08
... representation of integers Trang 48/4 Integer types Integers are whole numbers 0, -1, 1, -2, 2, etc Java has 4 integer types We most commonly use the int type Type name Memory used Size range Trang ... representation of real numbers Trang 11Type double Real numbers are numbers with a fractional part Java has two types of real numbers Scientific (floating-point) form 45678 = 4.5678 x 1040.0345 ... represent a single character (of almost any language) Examples 'a' '+' '3' Stored in 2 bytes Java uses Unicode scheme to represent characters Stored as an unsigned 16-bit integer Range
Ngày tải lên: 24/03/2016, 22:07
Giáo trình Java cơ bản 10
... Trang 11► Scanner class Trang 1210/12 Scanner class in this subject It is a new addition to the Java language in order to simplify using keyboard input can read in or check the different types ... class, we first have to tell the compiler where to look for it with the import command import java.util.*; Then, declare and instantiate a Scanner object Scanner keyboard = new Scanner(System.in); ... number of seconds is: 11556 Enter the number of hours: 3.2 Exception in thread "main" java.util.InputMismatchException * Notice that hours is of type integer in the program code, however
Ngày tải lên: 24/03/2016, 22:09
Giáo trình Java cơ bản 11
... in Java (1 < x) && (x < 10) is the solution 11/ 23 ► Logical operators 11/ 24... if…else statements, we get a structure often referred to as nested if 11/ 27 Class exercise Write a Java ... Operators String Comparison Bitwise Operators (Optional) 11/2 ► The if statement 11/3 if statement The Java if statement allows us to conditionally execute a statement The condition in brackets is ... two numbers (n1 and n2) IF n1 >= n2 THEN display n1 ENDIF IF n2 > n1 THEN display n2 ENDIF 11/8 Java Solution // get n1 and n2 if ( n1 >= n2 ) { System.out.println("max = " + n1 ); } if ( n2 >
Ngày tải lên: 24/03/2016, 22:09
Giáo trình Java cơ bản 16
... 10% per year (compounded yearly) – How long will it take for the balance to double itself? Trang 5Java solution double initialBalance = 1000; final double RATE = 0.10; double targetBalance = 2 ... stars Trang 37Example - addition table Write a program to display the addition table Trang 39Java Solution Trang 40Class exercise Write a loop structure to find all the prime numbers up
Ngày tải lên: 24/03/2016, 22:12
Giáo trình Java cơ bản 17
... Precedence Java operator precedence from highest to lowest – – – – – – – + - ++ ! (unary operators) * / % + (binary +, - operators) < > = == != && || *NB: This is not the full set of Java operators ... “or” are both commutative and associative Commutativity * Though be careful a || b b || a with Java’s short-circuit evaluation! a && b b && a Associativity a || (b || c) (a || b) || c a ... operators 17/ 13 Precedence... integer or floating point division is occurring 17/ 16 Evaluation Java uses short-circuit evaluation If the first part of an || is true, the second part of the
Ngày tải lên: 24/03/2016, 22:13
Giáo trình Java cơ bản 18
... to be called Trang 5318/53 Java files and separate compilation Each Java class needs to be in a separate file which has the same name as the class but with a java extension A class can ... Classes grouped and considered together describe and generate objects Trang 1018/10 Elements of a Java class Trang 1118/11 Abstractions programming) are abstractions – Simplified versions / representations ... them Trang 3318/33 Invoking a method To invoke a method in an object, we send it a message In Java, we specify the name of the object to receive the message and specify which of that object’s
Ngày tải lên: 24/03/2016, 22:14
Giáo trình Java cơ bản 20
... public String toString( ) Trang 33javadoc You can run javadoc on a single class or a whole package (explained later) On a single class javadoc MyClass.java Creates a file MyClass.html ... Java class libraries javadoc – program that extracts comments out of Java source files and creates an HTML file with the class interface information Trang 3020/30 javadoc See Appendix ... 2820/28 ► Javadoc (to generate documentation on classes) Trang 29Terminology API – Application Programming Interface – Specifies the interface of a Java class – Used to refer to the Java class
Ngày tải lên: 24/03/2016, 22:15
Giáo trình Java cơ bản 22
... this.<method> Trang 6Omitting this When we are referring to an attribute or method in the same object, Java lets us leave out the this object by <attribute> when there is no ambiguity (i.e name ... constants final public final static double PI = 3.14159; Trang 38The Math class In package java.lang – A package is a collection of classes functions public final static double PI
Ngày tải lên: 24/03/2016, 22:19
Giáo trình Java cơ bản 25
... general.utilities At the top of the DigitalClock.java file, I would have to place the package statement – package general.utilities; The directory myjavalibraries would have to be added to the ... environment variable so that Java would know to look for packages there Trang 50Packages Change your CLASSPATH variable in your .cshrc file setenv CLASSPATH ~myUserName/myjavalibraries: Separate ... import statement tells the compiler where to find the classes in the package To find a package Java needs – The name of the package – The classpath variable Trang 48Package names The package
Ngày tải lên: 24/03/2016, 22:21