Learning Computer Programming Using Java with 101 Examples

Execute Java Online. For most of the examples given in this tutorial, you will find a 'Try it' option, which you can use to execute your Java programs at 

Part of the document

Learning Computer
Programming using
Atiwong Suchato

Atiwong Suchato
1. Java (Computer program language).
ISBN 978-616-551-368-5
First Printing: July, 2011
All rights reserved. No part of this publication may be reproduced or
distributed in any forms or by any means without the prior written
consent of the author.
Published by
Department of Computer Engineering
Faculty of Engineering,
Chulalongkorn University
Phayathai, Bangkok, 10330
This book is a creation of the Knowledge Collection and Contribution
Initiatives by the Department of Computer Engineering, Chulalongkorn

To my parents, who have always committed
to providing the best education for me.

Computer programming skills are currently must-have skills for every
university graduate in any fields of Science and Engineering. This book
is aimed to be a textbook suitable to be used in a first programming
course for university-level students. The primary goals of this book are to
introduce students to creating computer programs to solve problems
with high-level languages. Programming concepts appearing in modern
programming languages are presented through writing Java programs.
Java is selected as the language of choice due to its relatively simple
grammars. It is also a good choice for introducing students to the concept
of object-oriented programming which is one of the most popular
paradigms in the current days. Furthermore, Java is one of the most
widely-adopted programming languages by the industries.
This book is developed from the class notes that the author wrote for the
introductory computer programming course offered to students in the
International School of Engineering, Chulalongkorn University. The
writing style and the content organization of this book is designed to be
straight-forward. Details not crucial to understanding the main materials
presented in their related sections are usually omitted in order to relieve
the readers from worrying about having to know 'too much'. References
for further readings will be given along the way.
The author hopes that this book would introduce readers to the joy of
creating computer programs and, with examples given in this book,
writing computer programs would appear to be more realizable,
especially for beginners with absolutely no programming background.
The source code used in all 101 examples, as well as possible list of errata,
can be found on the Facebook page of this book:

Typographical Conventions
The following typographical conventions are used in this book:
indicates new terms, class names, method names, and arithmetic
Bold constant width
indicates Java keywords, source codes, expressions used in their
related source codes.
About the Author
Dr. Atiwong Suchato is currently an assistant professor at the
department of Computer Engineering, Faculty of Engineering,
Chulalongkorn University. He earned his bachelor degree in Electrical
Engineering with the first-class honor from Chulalongkorn University
while being ranked in the 1
among the graduated class.
Dr. Suchato received the Anandamahidol foundation scholarship in 1997
to pursue his advanced degrees at Massachusetts Institute of Technology
(MIT). In 2004, he received his doctoral degree in Electrical Engineering
and Computer Science from MIT and joined the Department of
Computer Engineering, Faculty of Engineering, Chulalongkorn
University. Since then, Dr. Suchato has been teaching computer
programming courses to students in several programs including
programs in the International Engineering School (ISE), Chulalongkorn
University. He was appointed an assistant dean position overlooking the
Information Technology strategies and their implementation in 2008. He
was also a key member in the team that initiated the Information and
Communication Engineering (ICE) program for the faculty in 2005 as
well as the committee revising its curriculum in 2010.
His research interests are in the area of computerized speech and
language technologies and their applications to assistive technology.