Immediate download Java A Step by Step Guide for Absolute Beginners 1st Edition Daniel Bell ebooks 2024
Immediate download Java A Step by Step Guide for Absolute Beginners 1st Edition Daniel Bell ebooks 2024
com
https://ebookmeta.com/product/java-a-step-by-step-guide-for-
absolute-beginners-1st-edition-daniel-bell/
OR CLICK HERE
DOWLOAD NOW
https://ebookmeta.com/product/research-methodology-a-step-by-step-
guide-for-beginners-5th-edition-ranjit-kumar/
ebookmeta.com
https://ebookmeta.com/product/bayesian-statistics-for-beginners-a-
step-by-step-approach-therese-m-donovan/
ebookmeta.com
https://ebookmeta.com/product/indoor-grow-room-for-beginners-a-step-
by-step-guide-to-growing-marijuana-1st-edition-matthew-mcclure/
ebookmeta.com
https://ebookmeta.com/product/the-crypto-launderers-crime-and-
cryptocurrencies-from-the-dark-web-to-defi-and-beyond-1st-edition-
david-carlisle/
ebookmeta.com
https://ebookmeta.com/product/the-bloomsbury-handbook-to-cold-war-
literary-cultures-1st-edition-greg-barnhisel-editor/
ebookmeta.com
https://ebookmeta.com/product/commercial-real-estate-investing-for-
dummies-2nd-edition-peter-conti/
ebookmeta.com
Literary Britten Words and Music in Benjamin Britten s
Vocal Works Aldeburgh Studies in Music 13 Benjamin Britten
https://ebookmeta.com/product/literary-britten-words-and-music-in-
benjamin-britten-s-vocal-works-aldeburgh-studies-in-music-13-benjamin-
britten/
ebookmeta.com
JAVA
***
A Step-by-Step Guide for
Absolute Beginners
Daniel Bell
Please note the information contained within this document is for educational and
entertainment purposes only. No warranties of any kind are expressed or implied. Readers
acknowledge that the author is not engaging in the rendering of legal, financial, medical or
professional advice. Please consult a licensed professional before attempting any techniques
outlined in this book.
By reading this document, the reader agrees that under no circumstances is the author
responsible for any losses, direct or indirect, which are incurred as a result of the use of the
information contained within this document, including, but not limited to, errors, omissions,
or inaccuracies.
Java: A Step-by-Step Guide For Absolute Beginners
Copyright © 2019 by Daniel Bell.2nd Edition
All rights reserved. No part of this book may be used or reproduced in any manner
whatsoever without written permission except in the case of brief quotations em- bodied in
critical articles or reviews.
Under no circumstances will any legal responsibility or blame be held against the publisher
for any reparation, damages, or monetary loss due to the information herein, either directly
or indirectly.
Publisher: Amazon KDP & Guzzler Media LLC
http://www.guzzlermedia.com
Contact: [email protected]
Book and Cover design by Angela W.T.
ISBN:
Imprint: Independently published
First Edition: April 2019
CONTENTS
INTRODUCTION
1-GETTING STARTED WITH JAVA
What is Java?
Java Environment
First Java Program
2-JAVA CLASSES AND OBJECTS
Constructors
Creating Objects
Accessing Variables and Methods
3-VARIABLES IN JAVA
Variable Declaration
Variable Initialization
Variable Types
4-JAVA DATA TYPES
Primitive Data Types
Non-Primitive Data Types
Type Casting and Type Conversion
5-ARRAYS IN JAVA
Single Dimensional Arrays
Multi-Dimensional Arrays
6-OPERATORS IN JAVA
Unary Operator
Arithmetic Operators
Logical Operators
Comparison Operators
7-DECISION MAKING STATEMENTS
if statement
if…else statement
if...else if...else Statement
Nested if
switch statement
8-JAVA LOOPS
for Loop
while Loop
do…while Loop
break Statement
continue Statement
9-JAVA METHODS
Creating Methods
Calling Methods
The void Keyword
Call by Value
Abstract Methods
Method Overloading
Command-Line Arguments
The this Keyword
Variable Arguments
Method Overriding
Recursive Functions in Java
10-INHERITANCE IN JAVA
Single Inheritance
Multilevel Inheritance
Hierarchical Inheritance
Invoking Superclass Constructor
The instance of Keyword
11-ABSTRACTION IN JAVA
12-ENCAPSULATION
13-INTERFACES
14-PACKAGES
Import Keyword
15-JAVA APPLETS
Applets’ Lifecycle
Displaying Images
Applet Animations
Events on Applets
Applet Parameters
16-JAVA INPUT/ OUTPUT
Byte Streams
Character Streams
Standard Streams
Reading and Writing Files
File Navigation
Listing Directories
17-EXCEPTION HANDLING
Catching Exceptions
Multiple Catch Blocks
Throw/Throws Keywords
Finally Statement
Try-with-resources
User-defined Exceptions
18-JAVA AWT
Handling Events
AWT Button
AWT Label
AWT TextField
AWT TextArea
AWT Checkbox
AWT CheckboxGroup
AWT Menu and MenuItem
KeyListener Interface
CONCLUSION
ABOUT THE AUTHOR
ACKNOWLEDGMENTS
Introduction
Java is a great programming language that can be used for the
development of both standalone and distributed applications. These
types of applications are on high demand today for both small and
large enterprises. Java comes with a feature known as apples which
are web pages that can be embedded on web browsers. This means
that Java can help you add some functionality to your web
applications. You can now tell why Java is a popular programming
language with a high demand worldwide. It also has many other
features which you can take advantage of when developing your
application. For instance, Java is an object-oriented programming
language. If you are familiar with any other object-oriented
programming language, it will be easy for you to learn Java. Java
has a simple syntax easy to grasp, even by beginners.
It is easy to get started with writing and running Java programs. You
only need to have the Java compiler installed on your computer and
a text editor where you will write your code. With these, you can
write your Java programs and get instant results. For the case of the
text editor, a basic text editor like Notepad is okay although there
are more advanced text editors for Java-like NetBeans and Eclipse.
Once you compile your Java code, you get the Java byte-code which
is platform independent, meaning you can execute it on a machine
running any type of operating system. This book is an excellent
guide for you to learn everything about Java. The author takes you
from the initial steps of getting started with Java to develop your
own Java application. Enjoy reading!
1-Getting Started with
Java
What is Java?
Java is both a platform and a programming language. As a platform,
we have the Java runtime environment (JRE) which is a software
environment on which programs can run. As a language, Java is a
high-level, robust and object-oriented programming language. The
language was developed by Suns Microsystems in 1995.
Since Java is an object-oriented programming language, it treats
everything as an object. The object model nature of the language
also makes it easy for us to extend it. Java programs go through two
steps to generate results. The first step is compilation after which
the Java bytecode is generated. The Java bytecode is platform
independent, meaning that it can be run on any machine. After the
compilation, the bytecode is passed through the execution step to
generate the results.
Java is known to be an easy language. If you are familiar with the
concepts of object-oriented programming, then it will be easy for
you to understand Java. Java comes with a secure feature that
allows developers to create temper-free and virus-free systems. The
public-key encryption is used as a technique for securing the
systems.
Java Environment
To write and running your Java programs, you must have the Java
compiler and a text editor such as Notepad in Windows. To get the
Java compiler, you must install the Java Development (JDK) on your
computer. Once this is installed, your computer will have the Java
compiler.
Now you have the Java compiler, you must have a text editor in
which you will write your programs. You can use either a basic text
editor or an advanced text editor. Examples of advanced text editors
you can use for Java programming include NetBeans and Eclipse.
You can download the JDK from the following
URL:http://www.oracle.com/technetwork/java/javase/dow
nloads/jdk8-downloads-2133151.html
Once the download is complete, just double click the setup file and
the installation process will begin. You will be taken through a
sequence of simple on-screen instructions for the installation to be
done. Installation alone is not enough as you have to do something
for the Java installation directories to be known. You have to set the
path environment variable. This way, you will be able to invoke the
Java compiler from the terminal of your operating system. In most
cases, the installation of JDK is done in the c:\Program Files\java\jdk
directory. On windows, you can set the path environment variable by
right clicking “My Computer” then choosing “Properties”. Next,
open the “Advanced” tab then choose “Environment variables”.
Add the “c:\Program Files\java\jdk\bin” path. Linux users are
advised to read the documentation of their shells.
Once you have saved the above code, open the terminal of your
operating system and navigate to the directory where you have
saved the file.
Run the following command on the terminal:
javac Hello.java
java Hello
The above output shows that the code returned Hello World as the
output.
Consider the following line which I have extracted from the code:
What we are doing in the above line is that we are creating a class
named Hello. The H in the class name has been written in
uppercase; hence we must write the class that way anytime we are
referring to it. Java is a case sensitive language. The public is an
access modifier, declaring the class as public, meaning it can be
accessed from the rest of the classes contained within the same
package. The opening curly brace { marks the beginning of the body
of the class and to close it, we must use the closing curly brace }.
Consider the following section extracted from the code:
/* my first java program
* the code will print 'Hello World'
*/
System.out.println("Hello World");
We have called a method named println to help us print the text we
pass to it on the display. You have also noticed that we have used
two closing curly braces }}. The first one closes the main method
while the second one closes the class.
Other documents randomly have
different content
The Project Gutenberg eBook of Omenapuu
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.
Title: Omenapuu
Language: Finnish
Kirj.
John Galsworthy
Euripides, Hippolytos.
Omenapuu.
Hopeahääpäivänään olivat Ashurst ja hänen vaimonsa lähteneet
autoretkelle nummen ulkolaidalle, ja heidän aikomuksensa oli viettää
muistojuhlaansa yöpymällä Torquayihin, missä he olivat ensi kerran
tavanneet toisensa. Ajatuksen oli keksinyt Stella Ashurst, jonka
luonteessa oli hempeämielinen piirre. Vaikka hän olikin jo aikoja
menettänyt sinisten silmiensä kukkamaisen viehkeyden, kasvojen ja
vartalon hennon raikkauden ja hipiän omenankukan heleän värin,
mitkä kaikki olivat kuusikolmatta vuotta sitten niin äkkiä ja
odottamatta hurmanneet Ashurstin, hän oli vielä
kolmeviidettävuotiaana miellyttävä uskollinen elämäntoveri, jonka
poskien väri ei kylläkään enää ollut tasainen ja jonka siniharmaisiin
silmiin oli tullut hieman raskas ilme.
I.
Toukokuun ensimmäisenä päivänä, päätettyään viimeisen,
yhteisen ylioppilasvuotensa olivat Frank Ashurst ja hänen ystävänsä
Robert Garton jalkamatkalla. He olivat sinä päivänä lähteneet
Brentistä ja aikoivat vielä ehtiä Chagfordiin, mutta Ashurstin
jalkapallopolvi oli tehnyt tenän, ja kartasta päättäen heillä oli vielä
matkaa seitsemisen mailia. He istuutuivat penkille tien varteen, jota
sillä paikalla leikkasi pitkin metsätöyrään laitaa mutkitteleva
sivupolku, lepuuttamaan kipeää polvea ja juttelemaan kaikesta
taivaan ja maan väliltä, niin kuin nuorten miesten on tapana.
Molemmat olivat yli kuusi jalkaa pitkiä ja hoikkia kuin humalasalot.
Ashurst oli kalpea, ihanteellinen, hajamielinen, Garton omituisen
näköinen, luiseva, kulmikas ja kähärätukkainen kuin jokin
muinaisajan eläin. Molemmilla oli kirjallisia harrastuksia,
kummallakaan ei ollut hattua päässä. Ashurstin tukka oli hieno,
vaalea, aaltoileva ja osoitti taipumusta nousta pystyyn molemmin
puolin otsaa ikäänkuin taaksepäin heitettynä, Gartonin kuin tumma,
takkuinen pesuriepu. He eivät olleet tavanneet ainoaakaan ihmistä
monen mailin taipaleella.
"Ei ole lähitienoilla muita taloja kuin meidän." Tyttö puhui vapaasti,
ja hänen äänensä oli kaunis, pehmeä ja kirkas.
"Kyllä."
"Oletteko devonshireläisiä?"
"En."
"Walesista."
"Kas vain! Ajattelin juuri, että olette kelttiläinen. Ette siis kuulu
talonväkeen?"
"Entä enonne?"
"Hän on kuollut."
"Seitsemän vuotta."
"Sen uskon."
"Megan David."
"Se käy kyllä päinsä, jos tyydytte yhteen huoneeseen. Megan, laita
vierashuone kuntoon ja tuo maitovati sisään. Varmaankin juotte
teetä?"
Garton jatkoi:
III.
Unen pyörän oli tapana Ashurstin kohdalla kieppua nopeasti,
tasaisesti ja äänettömästi, mutta tällä kertaa hän oli, vaikka näyttikin
vaipuneen uneen, täysin hereillä toverin tullessa takaisin heidän
yhteiseen huoneeseensa. Ja vielä senkin jälkeen, kun Garton jo
peittoon kääriytyneenä matalakattoisen huoneen toisessa vuoteessa
palvoi pimeyttä nenänvarsi ylöspäin, hän kuuli pöllöjen huhuilun.
Jollei ottanut lukuun jomotusta polvessa, ei elämä tuntunut
hullummalta — elämän suruilla ei ollut suurtakaan sijaa tämän
nuoren miehen valvotuissa öissä. Itse asiassa ei hänellä suruja
ollutkaan. Hän oli juuri päässyt asianajajain kirjoihin, hänellä oli
kirjallisia taipumuksia ja koko maailma avoimena edessään. Isä ja
äiti olivat kuolleet, hänellä oli tuloja neljäsataa puntaa vuodessa.
Mitä siis merkitsi, minne hän matkusti, mitä teki tai milloin jotakin
teki? Hänen vuoteensa oli kova ja se varjeli häntä kuumeelta. Hän
loikoi valveilla, hengitti yön tuoksuja, joita tulvi huoneeseen
avoimesta ikkunasta aivan hänen päänalaisensa vierestä. Jollei
ottanut lukuun pientä harmintunnetta matkatoveria kohtaan, mikä oli
niin luonnollista, kun muistaa ystävysten olleen jo kolme päivää
kahden matkalla, Ashurstin muistot ja näyt olivat tuona unettomana
yönä leppoisia, kaihomielisiä ja liikuttavia. Varsinkin hän näki
edessään selvästi ja aiheettomasti — sillä hän ei ollut aikaisemmin
ollut tietoinen siitä, että olisi pannut niitä merkille — pyssyä
puhdistavan nuorukaisen kasvot ja niiden tarkkaavan, levollisen ja
kuitenkin säikähtyneen ilmeen tämän siirtäessä katseensa keittiön
ovesta tuoppeja kantavaan tyttöön. Tuo punakka, sinisilmäinen
naama, vaaleat silmäripset ja rohtimien kaltaiset hiukset olivat
syöpyneet hänen muistiinsa yhtä varmasti kuin tytön kasteenraikkaat
kasvot. Viimein hän näki uutimettoman ikkunan neliön vaalenevan ja
kuuli unisen, käheän kukonkiekaisun. Sitten seurasi hiljaisuus, joka
oli yhtä kuollut kuin ennen, kunnes mustarastas, tuskin vielä
hereillään, uskalsi rikkoa sen laulullaan. Ja tähystellen ikkunan
kehystämään valkenevaan päivään Ashurst vaipui uneen.
"Hän sanoi, että minä olen bardien tytär. Mitä ne sellaiset ovat?"
"Hän tarkoitti, että olette sellainen tyttö, joista heidän oli tapana
laulaa."
"Uskoisin kyllä."
Megan hymyili.
"Vai niin."
"Hän sanoi, että kaikki toiset pojat olivat oikeita mustalaisia. Sitä
hänen ei olisi pitänyt sanoa. Tätini kyllä nauroi, mutta hän ei pitänyt
siitä, ja serkkuni suuttuivat. Enoni oli maanviljelijä, eivätkä
maanviljelijät ole mustalaisia. On väärin loukata ihmisiä."
"On toki."
"Olen katsellut teitä, mutta en ole vielä sitä huomannut."
"Kauniita elukoita!"
Ontuvan miehen kasvot kirkastuivat. Hänellä oli silmissään
ylöspäin kääntynyt katse, jollaisen pitkäaikainen kärsimys usein
aiheuttaa.
"Ohoh"
"Mikä mustalaiskummitus?"
"En tiedä, en ole koskaan itse nähnyt. Megan sanoo, että sen on
tapana istua täällä. On vanha Jimkin sen kerran nähnyt. Se istui
tuossa sen päivän edellisenä iltana, jolloin poni potkaisi isää päähän.
Se soitti huilua."
"En tiedä."
"Mikä se on?"