JAVA NOTES BY PITAMBARA EDUCATORS
What is Java?
Java is a very popular high level programming language and has been used widely to create
various types of computer applications such as database applications, desktop applications, Web
based applications, mobile applications, and games among others.
What are the applications of Java?
Mobile applications (specially Android apps)
Desktop applications
Web applications
Web servers and application servers
Games
Database connection
Why Use Java?
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.)
It is one of the most popular programming language in the world
It is easy to learn and simple to use
It is open-source and free
It is secure, fast and powerful
A general-purpose programming language made for developers to write once run
anywhere that is compiled Java code can run on all platforms that support Java. Java
applications are compiled to byte code that can run on any Java Virtual Machine.
Execution phases of a program
Writing a program is done by a java programmer like you and me.
The compilation is done by the JAVAC compiler which is a primary Java compiler included
in the Java development kit (JDK). It takes Java program as input and generates bytecode
as output.
In the Running phase of a program, JVM executes the bytecode generated by the compiler.
Java Bytecode
The Javac compiler of JDK compiles the java source code into bytecode so that it can be executed
by JVM. It is saved as .class file by the compiler.
Java Development Kit(JDK):
It is a complete Java development kit that includes everything including compiler, Java Runtime
Environment (JRE), java debuggers, java docs, etc. For the program to execute in java, we need
to install JDK on our computer in order to create, compile and run the java program.
Why We call Java a platform-independent language
Compiler converts source code to bytecode and then the JVM executes the bytecode generated
by the compiler. This bytecode can run on any platform be it Windows, Linux, Mac OS which
means if we compile a program on Windows, then we can run it on Linux and vice versa. Each
operating system has a different JVM, but the output produced by all the OS is the same after
the execution of bytecode. That is why we call java a platform-independent language.
Comments in Java
Comments can be used to explain Java code, and to make it more readable. It can also be used to
prevent execution when testing alternative code.
Single-line Comments
Beginning a comment line with two consecutive forward slashes (//)
Java Multi-line Comments
Multi-line comments start with /* and ends with */.
Any text between /* and */ will be ignored by Java.