John Java introduction Welcome to this chapter on the features of the Java language Let s dive right into the notes 1 Simple Object Oriented and Familiar Java is a simple language building upon the C syntax while removing some of its complexities It is an object oriented language with the philosophy that everything is an object even primitive types Java is also familiar as it uses English keywords and avoids the use of punctuation for command delimiters Example In Java we declare a variable like this int myVariable instead of int myVariable as in C 2 Robust and Secure Java is robust meaning that it can handle runtime errors more gracefully It includes automatic memory management which includes a garbage collector to free up memory Java is also secure with a security manager that defines the access rules for classes Example In Java we can use the finalize method to perform cleanup actions before an object is garbage collected 3 Architecture Neutral and Portable Java is architecture neutral meaning that it is not tied to a specific hardware or operating system It is also portable meaning that a Java program can run on any platform that has a Java Virtual Machine JVM installed Example The Java code System out println Hello World will run the same on Windows Mac or Linux 4 High Performance Java is a compiled language with a just in time JIT compiler that translates Java bytecode into machine code at runtime This results in faster execution times and efficient memory usage Example In Java we can use the server command line option to enable the JIT compiler improving the performance of our program 5 Multithreaded Java supports multithreading allowing for the execution of multiple threads in a single program This leads to better performance and responsiveness Example In Java we can create a new thread like this Thread myThread new Thread 6 Dynamic and Extensible Java is dynamic meaning that it can adapt to a changing environment It is also extensible with the ability to add new features through the use of libraries and frameworks Example In Java we can use the java util package to add functionalities such as collections and date time handling Quote Java is the number one development platform It s the number one platform for desktop applications and it s the number one platform for mobile devices James Gosling creator of Java Anecdote Java was originally called Oak and was intended for use in interactive TV systems but the project was eventually abandoned The language was later renamed to Java and was released as a platform for interactive applications on the internet In conclusion Java is a powerful and versatile language with a range of features that make it an ideal choice for a variety of applications Whether you re building mobile apps web applications or enterprise systems Java has the tools and capabilities you need to succeed Evolution of java Sure I d be happy to help you summarize the history and evolution of Java in a profluence driven and engaging way I ll use a mix of storytelling quotes anecdotes and code samples to bring the content to life The Birth of Java Java was born out of a need for a platform independent programming language In the early 1990s James Gosling and his team at Sun Microsystems set out to create a language that would allow developers to write code that could run on any device regardless of the underlying hardware and operating system Here s a quote from James Gosling that highlights the motivation behind Java The original goal of Java was to develop a language that would allow people to write programs to small devices like set top boxes and mobile phones The first version of Java called Oak was released in 1995 However the name Oak was already taken so the team decided to change it to Java The name was inspired by coffee which was a popular beverage at the time among the development team The Evolution of Java Since its inception Java has gone through many versions and updates Here are some of the most significant milestones in its evolution Java 1 0 1996 Java 1 0 was the first production ready version of the language It introduced many of the features that Java is known for today such as automatic memory management exception handling and platform independence Java 2 1998 Java 2 also known as J2SE Java 2 Standard Edition was released in 1998 It introduced many new features such as Swing for creating graphical user interfaces JDBC for connecting to databases and RMI Remote Method Invocation for creating distributed applications Java 5 2004 Java 5 also known as Tiger was released in 2004 It introduced some significant changes to the language such as generics autoboxing and annotations Let s take a closer look at an example of generics Suppose we want to create a simple linked list class that can hold a list of integers Before Java 5 we would have to use raw types like this public class LinkedList private Node head public void add Object value head new Node value head private class Node private Object value private Node next public Node Object value Node next this value value this next next This code is error prone and requires explicit casting when we want to retrieve the values from the list With the introduction of generics in Java 5 we can create a type safe linked list like this public class LinkedList private Node head public void add T value head new Node value head private class Node private T value private Node next public Node T value Node next this value value this next next Now we can create a linked list of integers using the following code LinkedList list new LinkedList list add 1 list add 2 list add 3 As you can see the generic LinkedList class is much safer and easier to use than the raw type version Java 8 2014 Java 8 released in 2014 introduced many new features that changed the way we write Java code Some of the most significant changes include Lambdas and method references for functional programming The Stream API for performing operations on collections in a declarative way The Optional class for handling null values in a more elegant way Let s take a closer look at an example of lambda expressions Suppose we have a list of strings and we want to check if any of them are empty Before Java 8 we would have to write something like this List strings Arrays asList Hello World boolean isEmpty false for String s strings if s null s isEmpty isEmpty true break system out println List contains empty string isEmpty With the introduction of
View Full Document