Java, a high-level multi-paradigm programming language famous for its ability to compile to platform-independent bytecode. It was designed by James Gosling in 1990 at Sun Microsystems. One of its first demonstrations was the Star 7 PDA, which gave birth to the Java mascot, Duke.
Today, it's one of the world's most popular programming languages. It powers enterprise web apps with Spring Framework, big data pipelines with Hadoop, mobile apps on Android, and even things like the controller for NASA's Maestro Mars rover. What made Java innovative is that instead of compiling to machine code like C or C++, it compiles to bytecode that can run on any operating system without recompiling, which is made possible by executing the code with the Java Virtual Machine or JVM. It's both a compiled and interpreted language at the same time.
The computer just needs to have the Java Runtime Environment or JRE installed, and most of them do. For developers, this means write once, run anywhere. It's a strongly typed language with a curly brace syntax similar to the C family. However, it provides more high-level features like garbage collection, runtime type checking, and reflection. To get started, install the Java Development Kit or JDK, then create a file ending in.java.
Every Java program starts with a class name, which should also match the file name. The class is required to have a main method. This is where your code will start executing.
Inside the method, define a variable by starting with a type, followed by a name and value. We can then print it to the standard output using the built-in system class. Now, because we're inside of a class, we define functions as methods on this class.
The public keyword means that it can be used outside of this class, and static means that it's a member of the class itself, as opposed to an instance of the class. We then provide a type and name and return a value from it. You can define your own custom classes, which are blueprints for objects, then add attributes and methods to them. Use the new keyword to instantiate an object from the class. It feels very object-oriented, but has evolved to support functional patterns like anonymous lambda methods.
When your program is finished, use the compiler to generate a.class file, which contains the bytecode. Now use the java command to tell the JVM to interpret and run that file. Congratulations, you just built an enterprise-grade application!
This has been Java in 100 seconds. Hit subscribe for more short videos like this, and if we somehow get to 100,000 likes on this video, I'll do a full Java tutorial. Thanks for watching, and I will see you in the next one.