Java Programming for Human Beings.pdf

(2430 KB) Pobierz
Java Programming for
Human Beings
The Ultimate Beginner's Introduction
By Mohit Deshpande
© Zenva Pty Ltd 2015. All rights reserved
https://zenva.com
1
                                         
Learn Java and Android mobile app development on zenva.com
Introduction
Computers can do some amazing things: track trends in data to predict the stock market, 
identify text and handwriting in images, and even perform delicate surgery! Ironically, 
the computers that we praise so much are really the dumbest invention of mankind. They 
can’t do any of these things by themselves; they were told very precisely how to perform 
these operations by a human.
At the very low level, computers can only understand binary, ones and zeros, which are 
incomprehensible to humans. Imagine reading this book in binary! This one of the big 
motivations behind why people have invented programming languages: they are human­
readable, logical, and have a precise syntax that can be converted into binary to tell a 
computer what to do. Programmers, developers, and software engineers write source 
code in programming languages to build desktop apps, mobile apps, hardware interfaces, 
and even airplane controls!
The journey that we’re about to embark on will take us through one such programming 
language: Java. We’ll start our journey the same way we would start with any other 
programming language: building the iconic “Hello World” program. Beyond that, we’ll 
move on to talk about what variables are and how to define them. Building on our 
knowledge of variables, the next section will show us operations that we can perform on 
those variables. From that knowledge, we’ll use operators to make decisions in our 
programs and repeat code. Towards the end of this book, we’ll get to the real power 
behind Java: object­oriented programming.
“The journey of a thousand miles begins with one step.” – Lao Tzu
2
                                         
Learn Java and Android mobile app development on zenva.com
Author Bio
Mohit Deshpande is a professional mobile application developer, contractor, and 
instructor. He started programming at the age of eleven. During the great mobile 
revolution, he shifted focus to developing mobile apps with his first Android app running 
on a Samsung Galaxy S1 running Android 2.1 Eclair. Since then, he has been involved in
industry and research. He is a computer science and engineering student at The Ohio 
State University and works for the Department of Computer Science and Engineering as 
a researcher. During the university hackathon, he came in second place with an Android 
app that links a task with a location using a geofence. In what little spare time he has, he 
plays jazz and rock guitar and performs in the Ohio State Athletic Band on trumpet at 
various sporting events.
3
                                         
Learn Java and Android mobile app development on zenva.com
What is Java?
Java is a programming language originally developed by Sun Microsystems (now Oracle)
in 1991. Specifically, James Gosling is credited with Java’s creation. Since then, it’s had 
many revisions and has grown to be one of the most widely­used programming 
languages. On GitHub.com, a popular website to host software projects, there are well 
over a million projects that use Java. It’s used everywhere from native desktop 
applications that we run on our computers to web servers that bring us our favorite 
websites to mobile apps that we download to our phones. This is the type of 
programming language where one can just create a file and start coding without having to
configure any compiler to a specific system or memorizing messy terminal commands. 
This is even easier using other programs, called Integrated Development Environments 
(IDEs), to help with writing Java code.
4
                                         
Learn Java and Android mobile app development on zenva.com
Since its conception, the motto for Java has always been “Write Once, Run Anywhere.” 
This paradigm is becoming more standard to the world of programming languages. 
Decades ago, other popular languages, such as C and C++, have to be recompiled for 
each machine we run it on. The job of the compiler is to convert human­readable source 
code into binary that our computer can understand. However, Java’s compiler will 
convert Java source code into Java byte code, which can only be understood by the Java 
Virtual Machine (JVM). The JVM is installable on any major operating system: 
Windows, Mac OS X, Linux, and more. Therefore, a Java program can be run by any 
operating system that has the JVM installed. Odds are, our machine already has it 
installed by default. However, we’ll need to install the utilities that we can use to compile
our own Java code, and, although we could type in our Java code into a text editor, we’re 
going to use an IDE that will make writing Java code much easier.
5
                                         
Learn Java and Android mobile app development on zenva.com
Zgłoś jeśli naruszono regulamin