DEV Community

Raj
Raj

Posted on

Java

what is java?

Java is a high level programming language for building web ,desktop,mobile and enteriprise applications.java is platform independenat because it runs on the java virtual machine(jvm).java supports object oriented programming concepts link classes ,object,inheritance and polymorphism.secure and robust with strong memory management

core components

  • JDK java development kit contains the tools libraries and compiler needed to applications
  • JRM java runtime evironment provides the libreries and the jvm required to run compiled java programs
  • JVM java virtual machine translates bytecode into native machine instructions for the underlying operating system

types of data types

java define data a varible can hold and memory required to store it they are broadly divided into two categories

1.Primitive Data type Store simple values directly in memory.

2.Non Primitive (Reference) Data types Store memory references to objects.

Primitive Dta types

Primitive data types are the basic built-in data types in Java. They are used to store simple values such as numbers, characters, and true or false values.Java has 8 primitive data types.

1. byte
The byte data type is used to store small integer values. It takes 1 byte of memory(Range: -128 to 127).

2. short
The short data type is used to store integer values that are larger than byte. It takes 2 bytes of memory(Range: -32,768 to 32,767).

3. int
The int data type is used to store whole numbers. It is commonly used for storing integer values. It takes 4 bytes of memory.

4. long
The long data type is used to store very large whole numbers. It takes 8 bytes of memory.

5. float
The float data type is used to store decimal numbers. It takes 4 bytes of memory.

6. double
The double data type is used to store decimal numbers with more precision than float. It takes 8 bytes of memory.

7. char
The char data type is used to store a single character. It takes 2 bytes of memory in Java.
**

  1. boolean** The boolean data type is used to store only two values: true or false.

*Non-Primitive (Reference) Data Types *

Non-primitive data types, also called Reference Data Types, are used to store and work with more complex data in Java.

1. String
String is used to store a sequence of characters (text). We use double quotes to create a String.

2. Array
An Array is used to store multiple values of the same data type in a single variable.

3. Class
A Class is a blueprint for creating objects. It defines variables and methods that describe the properties and behaviours of objects.

4. Object
An Object is an instance of a class. It represents a real-world entity and contains data and behaviour.

5. Interface
An Interface is used to define a contract that classes can implement. It contains method declarations that implementing classes provide with their own implementations.

6. Enum
Enum (Enumeration) is used to define a fixed set of constants.

Top comments (0)