Data types and variables
String manipulation
Conditionals
Loops
Methods
Arrays and Lists (collections)
Classes and Objects
What is Java?
Java is one of the most widely used programming languages. It was created in 1991 by James Gosling, a Canadian computer scientist.
Java is a general-purpose language that can be compiled and run on any operating system (OS) that runs a Java Virtual Machine (JVM). This means that you can write code once and run it anywhere.
Why should I learn Java?
Java is easy to learn, has excellent documentation, and is used everywhere: from smartphones to supercomputers. Here are some resources from our site if you’re interested in learning more about Java.
Courses:
Java for Complete Beginners (Udemy)
Java Fundamentals for Absolute Beginners (Microsoft Virtual Academy)
Books:
Head First Java, 2nd Edition (O’Reilly)
The Java Programming Language, 4th Edition (Addison-Wesley Professional)
Introduction
Java is one of the most popular programming languages and the foundation for hundreds of thousands of applications and devices. This cheat sheet will help you remember helpful syntax that is not used often enough.
Getting Started
The first step to writing Java programs is to ensure that you have the Java Development Kit installed on your computer, as it contains all the tools needed to write, compile, and run Java applications.
You also need a text editor to write your code in. Programming editors like Sublime Text or Atom are good for this.
Hello World!
All Java programs start with a class name. The class name can be any valid identifier (alphabet, numbers, dollar sign or underscore) but should begin with an alphabet letter:
Java is a programming language.
It is used to develop desktop and mobile applications, big data processing, embedded systems, and so on.
According to Oracle, the company that owns Java, Java runs on 3 billion devices worldwide
public Person() {
this.name = “John”;
}
public Person(String name) {
this.name = name;
}
public String getName() {
return name;
}
Java is one of the most popular programming languages, developed by James Gosling. It is used for coding and compiling of applications for several platforms such as Windows, Android and Linux operating systems.
Java has a robust, object-oriented design with a simple syntax that makes it easy to learn and use. Java was designed to have the look and feel of the C++ language. It offers a small, concise, and object-oriented approach. Java’s popularity is mainly due to its portability feature, which allows users to run the same program on multiple operating systems.
Java allows developers to write code once and run it on any computer without having to recompile it. This is possible because of Write Once Run Anywhere (WORA) feature of Java. Java compiler translates Java source code into Bytecode, which can be executed in any environment that has JRE installed on it.
public class Main {
public static void main(String[] args) {
System.out.println(“Hello World!”);
}
}
// the output will be “Hello World!”
// a variable is a container for a value that can be changed later on.
int myNum = 5; // integer (whole number)
float myFloatNum = 5.99f; // floating point number
char myLetter = ‘D’; // character
boolean myBool = true; // boolean
String myText = “Hello”; // string (a sequence of characters)
Tomy is a contributor at AskMeCode. We are committed to providing well-researched, accurate, and valuable content to our readers.
You May Also Like
Python Factorials
Factorials are a fundamental element in many functional programming languages, including Python. Factorials are useful in teaching functional programming because...
How To Teach Yourself Coding
I have been coding for over 20 odd years and I have always wanted to distill that knowledge into a...
Use the Right Tool for the Job, the advantages and limitations of JSLint
The advantages and limitations of JSLint: a blog about when to use JSLint. JSLint is an excellent tool for catching...
A Gentle Introduction to Flask
Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions. And before you ask: It’s BSD...
