Lecture An introduction to computer science using java (2nd Edition): Chapter 2 - S.N. Kamin, D. Mickunas, E. Reingold

Chapter 2 - Classes and methods I. In this chapter we will: describe structure of Java programs, present techniques for creating and using class instances, introduce two classes for doing output: OutputBox for text output, DrawingBox for graphical output. | Chapter 2 Classes and Methods I Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by . Kamin, D. Mickunas, E. Reingold Chapter Preview In this chapter we will: describe structure of Java programs present techniques for creating and using class instances introduce two classes for doing output: OutputBox for text output DrawingBox for graphical output Running Java Programs Enter the program source code in a data file called using an editor Compile the source program by typing javac Execute the compiled program by typing java Hitwall Program Elements – Part 1 white space blank lines and spaces includes in program source listings to make things more readable comments lines beginning with two slashes // single or multiple lines enclosed by /* */ that allow the programmer to insert notes to help other people understand the program documentation program comments and data files describing a program’s structure and behavior Program Elements – Part 2 import directive tells the Java compiler which packages the program makes use of packages predefined collections of programs providing services to many programmers (. CSLib.* package used throughout the text) class heading needs to be included at the beginning of every program class name must match root of file name each class must be stored in a file of its own Program Elements – Part 3 main method the chief computational unit of a Java application executed first when application is run functions also known as methods define operations that may be applied to a Java data object (class instance) body Java statements that contain the implementations of classes and their methods Program Elements – Part 4 variable declaration statement giving the name and data type of a data location used by the program executable statement statement which manipulates variables or determines program control during execution atomic statements single Java expressions terminated by | Chapter 2 Classes and Methods I Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by . Kamin, D. Mickunas, E. Reingold Chapter Preview In this chapter we will: describe structure of Java programs present techniques for creating and using class instances introduce two classes for doing output: OutputBox for text output DrawingBox for graphical output Running Java Programs Enter the program source code in a data file called using an editor Compile the source program by typing javac Execute the compiled program by typing java Hitwall Program Elements – Part 1 white space blank lines and spaces includes in program source listings to make things more readable comments lines beginning with two slashes // single or multiple lines enclosed by /* */ that allow the programmer to insert notes to help other people understand the program documentation program comments and data files describing a program’s structure and behavior .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.