Java
History.
Java was actually invented
for television but the language was too advanced. The history of Java started
with the Green Team (1991). It
suited Internet technology then and was incorporated into Netscape.
The principles for
creating Java were Simple, Robust, Portable, Platform-independent, Secured,
High Performance, Multithreaded, Architecture Neutral, Object-Oriented,
Interpreted, and Dynamic"
The main founder was James
Gosling.
Initial
name
Oak.
The team later renamed it
to Java since it was fun and since they consumed a lot of coffee.
Official
Launch
It was launched by Sun
Microsystems in 1995. This is the reason
it became known as Sun Java.
The
features of Java:
The Reason for Creation of Java
Java was created since C
and C++ were not platform-dependent. The Green team was developing a language
for TV, setup boxes. C++ was considered but it consumed too much memory.
Why
Learn Java
There are various reasons:
·
Rich API-lot in the library
·
Easy to Learn
·
Create Job Opportunities
·
Community Support
·
Object Oriented
Downloading
Java
Java is owned by Oracle,
the leader in database management systems.
https://www.oracle.com/java/technologies/downloads/#jdk21-windows
Choose your system:
Windows 64-Bit or Linux.
The latest is JDK21. I had
first used JDK 8.0 that was a long time ago when Java was owned by Sun
Microsystems.
: Syntax and Structure of Java
Java has the following.
·
Objects
·
Classes
·
Methods
·
functions
·
Instances
·
Variables
What
is a class?
A class is collection of
code to do particular tasks and has certain properties. For example class Car.
Public class Car {
Public static void main (String
args[])
}
The class is called
Car. Inside we have a function called
Public static void main ().
The
main function
Public
static void main
Public
means
it is accessible by all other methods in the class.
Static
because
JVM does not have to create an instance of the class while creating it.There is
no class object existing since this is the beginning.
Suppose we run program
without main class having a static
keyword.
class PrepBytes {
// do not define main() method as static
public void main(String[] args){
System.out.println("Non-static
Main method.");
}
}
The
error would be
The
program compiled successfully, but main class was not found.
Main class should contain method: public static void main
To be continued.