Saturday 24 August 2019

Java Tutorials | History of Java

Java Version History
The history of Java is very interesting. Java was originally designed for interactive television, but it was too advanced technology for the digital cable television industry at the time. Java team members initiated this project to develop a language for digital devices such as set-top boxes, televisions, etc. However, it was suited for internet programming. Later, Java technology was incorporated by Netscape.

The principles for creating Java programming were Simple, Robust, Portable, Platform-independent, Secured, High Performance, Multithreaded, Architecture Neutral, Object-Oriented, Interpreted and Dynamic.

Currently, Java is used in internet programming, mobile devices, games, e-business solutions, etc. There are given significant points that describe the history of Java.

Java History from Oak to Java
James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. Originally designed for small, embedded systems in electronic appliances like set-top boxes.

The small team of sun engineers called Green Team so it was called Greentalk by James Gosling, and file extension was .gt.

After that, it was called Oak and was developed as a part of the Green project.

Why Java named "Oak"?
Oak is a symbol of strength and chosen as a national tree of many countries like the U.S.A., France, Germany, Romania, etc.


In 1995, Oak was renamed as "Java" because it was already a trademark by Oak Technologies.

Why Java Programming named "Java"?
The team gathered to choose a new name. The suggested words were "dynamic", "revolutionary", "Silk", "jolt", "DNA", etc. They wanted something that reflected the essence of the technology: revolutionary, dynamic, lively, cool, unique, and easy to spell and fun to say.

According to James Gosling, "Java was one of the top choices along with Silk". Since Java was so unique, most of the team members preferred Java than other names.




  • Java is an island of Indonesia where first coffee was produced (called java coffee).
  • Notice that Java is just a name, not an acronym.
  • Initially developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995.

In 1995, Time magazine called Java one of the Ten Best Products of 1995. JDK 1.0 released in (January 23, 1996).

Java Version History
Many java versions have been released till now. See details below.

JDK Alpha and Beta (1995)
JDK 1.0 (23rd Jan 1996)
JDK 1.1 (19th Feb 1997)
J2SE 1.2 (8th Dec 1998)
J2SE 1.3 (8th May 2000)
J2SE 1.4 (6th Feb 2002)
J2SE 5.0 (30th Sep 2004)
Java SE 6 (11th Dec 2006)
Java SE 7 (28th July 2011)
Java SE 8 (18th March 2014)
Java SE 9 (21st Sep 2017)
Java SE 10 (20th March 2018)

Java Tutorials | Variables in Java



A variable is a name given to a memory location which can be used to perform operations on the value stored in the memory location. It is the basic unit of storage in a program and the value stored in the variable can be changed during program execution.

In Java, all the variables must be declared before use.

How to declare variables?




datatype: Type of data that can be stored in this variable.
variable_name: Name given to the variable.
value: It is the initial value stored in the variable.

Examples
float interestRate; // Declaring float variable
int speed = 20; // Declaring and Initializing integer variable
char var = 'h'; // Declaring and Initializing character variable

Types of variables
Local Variables
Instance Variables
Static Variables




Local Variables
A variable defined within a block or method or constructor is called local variable.
These variables are created when the method or constructor is called and destroyed after exiting from the method or constructor.
The scope of these variables exists only within the block in which the variable is declared. i.e. we can access these variables only within that method/constructor.

public class EmployeeAge {

            public static int getAge(int dobYear) {
                        // local variable age
                        int age = 0;
                        int currentYear = 2019;
                        age = currentYear - dobYear;
                        return age;
            }

            public static void main(String args[]) {
                        System.out.println("Age of Rajesh: " + getAge(1991));
            }
}
Output:
Age of Rajesh: 28

Important points about local variable
  • Initialization of Local Variable is Mandatory.
  • A local variable cannot be defined with the static keyword.

Instance Variables
Instance variables are non-static variables and are declared in a class outside any method, constructor or block.

As instance variables are declared in a class, these variables are created when an object of the class is created and destroyed when the object is destroyed. Unlike local variables, we may use access specifiers for instance variables. If we do not specify any access specifier, then the default access specifier will be used.

class Student {
            public String name;
            public int age;
            public int rollNo;

            public Student(String name) {
                        this.name = name;
            }
}

public class TestInstanceVariable {

            public static void main(String[] args) {
                        Student std1 = new Student("Nitin");
                        std1.age = 19;
                        std1.rollNo = 1;

                        Student std2 = new Student("Arun");
                        std2.age = 20;
                        std2.rollNo = 2;

                        System.out.println("\nStudent1 information");
                        System.out.printf("Name:%s Age:%d RollNo:%d ", std1.name, std1.age, std1.rollNo);

                        System.out.println("\nStudent2 information");
                        System.out.printf("Name:%s Age:%d RollNo:%d ", std2.name, std2.age, std2.rollNo);
            }
}

As you can see in the above program age, rollNo and name are instance variables. In case we have multiple objects, each object will have its own copies of instance variables. It is clear from the above output that each object will have its own copy of the instance variable.

Important points about instance variable
  • Initialization of instance variable is not Mandatory. If it not declared, will be assigned to default value.
  • Instance Variable can be accessed only by creating objects.

Static Variables
Static variables are also known as Class variables.
Static variables are declared similarly as instance variables, the only difference is, static variables are declared using the static keyword within a class outside any method or constructor.
Unlike instance variables, we can only have one copy of a static variable per class irrespective of how many objects we create.
Static variables are created when the class is loaded in JVM and destroyed the end of executions.

class StudentSectionC {
            public String name;
            public static String section;

            public StudentSectionC(String name) {
                        this.name = name;
            }
}

public class TestInstanceVariable {

            public static void main(String[] args) {
                        StudentSectionC std1 = new StudentSectionC("Nitin");
                        StudentSectionC std2 = new StudentSectionC("Arun");
                        StudentSectionC.section = "C";

                        System.out.println("\nStudent1 information");
                        System.out.printf("Name:%s Section:%s ", std1.name, std1.section);

                        System.out.println("\nStudent2 information");
                        System.out.printf("Name:%s Section:%s ", std2.name, std2.section);
            }
}
Output:
Student1 information
Name:Nitin Section:C
Student2 information
Name:Arun Section:C

Important points about static variable
  • Initialization of Static Variable is not Mandatory. If it not declared, will be assigned to default value like instance variables.
  • To access static variables, we need not create an object of that class, we can simply access the variable using the class name only.
  • If we access the static variable like Instance variable (through an object), the compiler will show the warning message and it won’t halt the program. The compiler will replace the object name to class name automatically.
  • If we access the static variable without the class name, Compiler will automatically append the class name.
Related Posts Plugin for WordPress, Blogger...