You are on page 1of 300
Your Key to Learning by Douglas Downing, Ph.D. Be ce tel ee. Casco rR eee hay The Easy Way... f If you want to improve your computer skills... = = Read this book! It was written for you. Bremen oa es cent tore tee a Acknowledgments This book would not be possible without the support of my wife Lori; and with help from Robert Downing for reviewing the manuscri; Mark Yoshimi for introducing me to Java; Melody Covington for type- setting the manuscript with TeX; Alec Hill and Seattle Pacific University for their support; the sponsors of the annual JavaOne conference; and editor Lynne Vessie at Barron's Educational Series, Inc. About the Author Douglas Downing teaches economics and quantitative methods and is undergraduate program chair for the School of Business and Eco- nomics at Seattle Pacific University. He earned a B.S. and Ph.D. at Yale University, and has written 14 books on math and computers. Trademarks Java is a trademark of Sun Microsystems, Inc. Windows is a trade- mark of Microsoft, Inc. This book is published by Barron's Educational Series, Inc. independently of these (or any other) company. © Copyright 1999 by Douglas Downing All rights reserved, No part of this book may be reproduced in any form, by photostat, microfilm, xerography, or any ather means, or incorporated into any information retrieval system, electronic or mechanical, without the written permission of the copyright owner. All inquiries should be addressed to: Barron's Educational Series, Inc. 250 Boulevard Hauppauge, New York 11788 hitpztwww.barronseduc.com Library of Congress Catalog No. 98-4374! International Standard Book No. 0-7641-0752-6 Library of Congress Cataloging-in-Publication Data Downing, Douglas. Java™ programming, the easy way / Douglas Downing. Pp. cm. — (The easy way} Includes bibliographical references and index. ISBN 0-7641-0752-6 (paperback) i. Java (Computer program language) I. Tide. Il. Series. QA76.73.I38D68 1999 005,13'3de2! 9843741 cr PRINTED IN THE UNITED STATES OF AMERICA 987654321 CONTENTS 1 Introduction to Java Programming 1 1.1 Computers and Programming Languages 00D i 3 1.4 Compiling and Running a Java Program & 2.1 Subtraction, Multiplication, and Division 2.2 Including Output Labels 2.3 Variables of Type double (Real Numbers) 2.4 Assignment Statements 2.5 Rounding Numbers 2.6 Input from a Command Line Parameter 2.7 Character String (String) Variables 2.8 Integer (Int) and Other Numerical Variables EXERCISES 00 alsa SelBl=|Slo 3 lets 24 zi tion Example Applet 3.2 Applets and HTML 26 3.3 Publishing an Applet on the World Wide Web 28 3.4 Includiny in Applets 29 3.5 Adding Sound to an Applet 30 3.6 Which to Use: Application or Applets? ES 4 u 4.1 Iffelse Statements 8 4.2 Logical Conditions 36 4.3 AND (@&), OR (jj), NOT () 36 4.4 The switch Statement: Choosing Between Several 4.5 Boolean Variables: true orfalge 90 EXERCISES

You might also like