In this chapter we will learn how to use variable and datatypes in Java.
the Following are the most commonly use datatypes in java :
byte (number, 1 byte)
short (number, 2 bytes)
int (number, 4 bytes)
long (number, 8 bytes)
float (float number, 4 bytes)
double (float number, 8 bytes)
char (a character, 2 bytes)
boolean (true or false, 1 byte)
The code below shows how to use these datatypes and variables
/************************************************************************* * Variables and Types in Java * *************************************************************************/ package lesson1; public class MyClass { /* byte (number, 1 byte) short (number, 2 bytes) int (number, 4 bytes) long (number, 8 bytes) float (float number, 4 bytes) double (float number, 8 bytes) char (a character, 2 bytes) boolean (true or false, 1 byte)*/ public static void main(String[] args) { int my_int = 10; float my_float = (float) 6.7; double my_double = 111.77; char my_char = 'A'; boolean my_bool = true; System.out.println(my_int); System.out.println(my_float); System.out.println(my_double); System.out.println(my_char); System.out.println(my_bool); } }
java is a programming language and computing platform first released by Sun Microsystems in 1995. There are lots of applications and websites that will not work unless you have java installed, and more are created every day.
java was developed by Sun microsystem as an Object oriented language for general purpose business applications. The target of java is to write a program once and then run this program on multiple operating systems.The first publicly available version of java ( java 1.0) was released in ‘95. Sun Microsystems was acquired by the Oracle Corporation in 2k10. Oracle has now the steermanship for java . In 2k06 Sun started to make java accessible under the GNU General Public License (GPL). Oracle continued this plan called Open JDK.
Over time new improved versions of java have been released. The present version of java is java 1.9 which is also known as java 9.
java is defined by a specification and consists of a programming language, a compiler, core libraries and a runtime ( java virtual machine) The java runtime permit software developers to write program code in other languages than the java programming language which still runs on the java virtual machine. The java platform is usually associated with the java virtual machine and the java core libraries.
The java syntax is similar to C++. java is case-sensitive, e.g., variables called myValue andmyvalue are treated as different variables.
Basic topics Covered in java is :
Introduction of java
JDK vs JVM vs JVM
Java Data Types
Java Operators
Java Loop Control
Java Decision Making
Java Array
Java String
Class And Object
This Keyword in Java
Static Keyword in Java
Constructor in Java
Overloading in Java
Overriding in Java