Introduction To Java for Beginners
What is JAVA ?
Java is a popular programming language created by James Gosling in 1995. Java is mostly used for:
- Mobile applications (Android).
- Desktop applications.
- Web applications.
- Web servers and application servers.
Java Variables
The usage of variables in Java is same as in other programming languages. Basically, variables are containers for storing data values.
Types:
- String: “Hello”
- int: 111 or -111
- float: 11.11 or -11.11
- char: “a” or “A”
- boolean: True or False
Declaring Variables
In order to create a variable in Java, the type must be specified before assigning a value to it.
Syntax) type variableName = value;
Ex) String fName = “James”;
Ex) int Age = 13;
Ex) boolean bool = true;
!!! Note: It will generate an error if the type specified does not match the value assigned.
!! Note: It is a better practice to use descriptive names when declaring variable. It will help other developers and yourself to understand it better.
Good Example:
Int currentYear = 2020;
Bad Example:
Int y = 2020;