Read without ads and support Scribd by becoming a Scribd Premium Reader.
 
Introduction to Programming Using Java
Version 5.0, December 2006
(Version 5.0.1, with typographical corrections, May 2007)
David J. Eck
Hobart and William Smith Colleges
 
iic
2006, David J. Eck
David J. Eck (eck@hws.edu)Department of Mathematics and Computer ScienceHobart and William Smith CollegesGeneva, NY 14456This book can be distributed in unmodified form with no restrictions.Modified versions can be made and distributed provided they are distributedunder the same license as the original. More specifically: This work islicensed under the Creative Commons Attribution-Share Alike 2.5 License.To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5thFloor, San Francisco, California, 94105, USA.The web site for this book is: http://math.hws.edu/javanotes
 
Contents
Preface xiii1 The Mental Landscape 1
1.1 Machine Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Asynchronous Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 The Java Virtual Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.4 Building Blocks of Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.5 Object-oriented Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.6 The Modern User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.7 The Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Quiz on Chapter 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2 Names and Things 19
2.1 The Basic Java Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.2 Variables and Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222.2.1 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232.2.2 Types and Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242.2.3 Variables in Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272.3 Objects and Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282.3.1 Built-in Subroutines and Functions . . . . . . . . . . . . . . . . . . . . . . 292.3.2 Operations on Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322.3.3 Introduction to Enums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342.4 Text Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362.4.1 A First Text Input Example . . . . . . . . . . . . . . . . . . . . . . . . . . 372.4.2 Text Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382.4.3 TextIO Input Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392.4.4 Formatted Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412.4.5 Introduction to File I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432.5 Details of Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442.5.1 Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452.5.2 Increment and Decrement . . . . . . . . . . . . . . . . . . . . . . . . . . . 462.5.3 Relational Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462.5.4 Boolean Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472.5.5 Conditional Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482.5.6 Assignment Operators and Type-Casts . . . . . . . . . . . . . . . . . . . . 482.5.7 Type Conversion of Strings . . . . . . . . . . . . . . . . . . . . . . . . . . 502.5.8 Precedence Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502.6 Programming Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51iii
Search History:
Searching...
Result 00 of 00
00 results for result for
  • p.
  • Notes
    Load more