Lecture Data structures and algorithms in Java (6th edition): Chapter 1 - Goodrich, Tamassia, Goldwasser

Java primer 1: Types, classes and operators. In Java, executable statements are placed in functions, known as methods, that belong to class definitions. The Universe class, in our first example, is extremely simple; its only method is a static one named main, which is the first method to be executed when running a Java program. | Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types, Classes and Operators © 2014 Goodrich, Tamassia, Goldwasser Java Primer 1 1 The Java Compiler q   q   Java is a compiled language. Programs are compiled into byte-code executable files, which are executed through the Java virtual machine (JVM). n   q   q   The JVM reads each instruction and executes that instruction. A programmer defines a Java program in advance and saves that program in a text file known as source code. For Java, source code is conventionally stored in a file named with the .java suffix (., ) and the byte-code file is stored in a file named with a .class suffix, which is produced by the Java compiler. © 2014 Goodrich, Tamassia, Goldwasser Java Primer 1 2 1 Java Primer 1 3/18/14 An Example Program © 2014 Goodrich, Tamassia, Goldwasser Java Primer 1 3 Components of a Java Program q   q   q   In Java, executable statements are placed in functions, known as methods, that belong to class definitions. The static method named main is the first method to be executed when running a Java program. Any set of statements between the braces “{” and “}” define a program block. © 2014 Goodrich, Tamassia, Goldwasser Java Primer 1 4 2 Java Primer 1 3/18/14 Identifiers q   q   The name of a class, method, or variable in Java is called an identifier, which can be any string of characters as long as it begins with a letter and consists of letters. Exceptions: © 2014 Goodrich, Tamassia, Goldwasser Java Primer 1 5 Base Types q   q   Java has several base types, which are basic ways of storing data. An identifier variable can be declared to hold any base type and it can later be reassigned to hold another value of the same type. © 2014 Goodrich, Tamassia, Goldwasser Java Primer 1 6 3 Java Primer .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
11    218    2    27-04-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.