I would like to go in detail on this.

Firstly Java is a strongly typed language i.e. before using any data we need to tell the complier of what data type this data will be.

In simple words we need to declare the data type of the variable.

Basically there are three type of data types:

  1. Primitive data types
  2. Derived data types
  3. User defined data types

Primitive data types are the general and fundamental data types that we have in Java and those are byte, short, int, long, float, double, char, boolean.

Derived data types are those that are made by using any other data type for example, arrays.

User defined data types are those that user / programmer himself defines. For example, classes, interfaces.

In very-very simple words I can say,

int a

Here a is a variable of int data type.

MyClass obj

Here obj is a variable of data type MyClass and we call them reference variables as they can be used to store the reference to the object of that class.

Answer from gprathour on Stack Overflow
Top answer
1 of 4
3

I would like to go in detail on this.

Firstly Java is a strongly typed language i.e. before using any data we need to tell the complier of what data type this data will be.

In simple words we need to declare the data type of the variable.

Basically there are three type of data types:

  1. Primitive data types
  2. Derived data types
  3. User defined data types

Primitive data types are the general and fundamental data types that we have in Java and those are byte, short, int, long, float, double, char, boolean.

Derived data types are those that are made by using any other data type for example, arrays.

User defined data types are those that user / programmer himself defines. For example, classes, interfaces.

In very-very simple words I can say,

int a

Here a is a variable of int data type.

MyClass obj

Here obj is a variable of data type MyClass and we call them reference variables as they can be used to store the reference to the object of that class.

2 of 4
1

In JAVA there are two types of data types are available, they are

   1. Primitive datatypes

   2. User Defined datatype

Basically, the primitive data types are predefined. like int, char, float, etc. if you want to store the data of types integer, character, then you can use these predefined datatypes happily. what if, if you want to store the data of your own type like Student, Employee, which is basically a combination of primitive datatypes, then here we have to go with user-defined data type, for this we can use Classes in java to store data of your own

🌐
DataFlair
data-flair.training › blogs › java-data-types
Java Data Types - Primitive & Non-Primitive Data types with Examples - DataFlair
May 7, 2026 - Without primitive data types, it would be impossible to frame programs. Primitive data types are also the building blocks of Non-primitive data types. There are 8 types of Java primitive data types, namely: 1. Int 2. Float 3. Char 4. Boolean 5.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-data-types
Java Data Types - GeeksforGeeks
Java provides two main categories: primitive and non-primitive data types. Memory allocation determines how much memory is required for each variable · Operations support defines what operations can be performed on data
Published: 2 weeks ago
🌐
Tutorialspoint
tutorialspoint.com › java › java_basic_datatypes.htm
Java - Data Types
String: The string is a class in Java, and it represents the sequences of characters. Arrays: Arrays are created with the help of primitive data types and store multiple values of the same type. Classes: The classes are the user-defined data types and consist of variables and methods.
🌐
Oracle
docs.oracle.com › javase › tutorial › java › nutsandbolts › datatypes.html
Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)
Doing so tells your program that ... the operations that may be performed on it. In addition to int, the Java programming language supports seven other primitive data types....
🌐
W3Schools
w3schools.com › java › java_data_types.asp
Java Data Types
Every variable in Java has a data type - primitive types like int and boolean, or non-primitive types.
🌐
Scribd
scribd.com › document › 283848091 › User-Defined-Data-Types
User-Defined Data Types in Java | PDF | Pointer (Computer Programming) | Data Type
- A class acts as a blueprint or template that defines common attributes and behaviors of objects of that class. An object is an instance of a class, with its own set of property values. - The document discusses various types of user-defined data types including enumerations, pointers, sets, records, classes/objects.
Rating: 5 ​ - ​ 1 votes
🌐
Jtcindia
jtcindia.org › tutorials › java › Data-Types.php
Java Data Types - Primitive and Non-Primitive Explained
User-defined data types are of the following kinds: • Class • Interface • Enum • Annotation [we will discuss in further tutorials] In Java, class is a user-defined data-type in which we can write the following different members.
Find elsewhere
🌐
Sololearn
sololearn.com › en › Discuss › 1946036 › what-are-userdefined-data-types-in-java
What are user-defined data types in Java? | Sololearn: Learn to code for FREE!
As per there are two types: Primitive data types [int,float..etc]. Reference type/Object type[String str, user_defined_Class Obj1..etc] I did search on this, but couldn't get a proper answer.
🌐
Sanfoundry
sanfoundry.com › java-data-types
Data Types in Java - Sanfoundry
December 31, 2025 - Classes in Java are user-defined reference types that can have fields (variables) and methods (functions).
🌐
JanBask Training
janbasktraining.com › community › qa-testing › what-are-data-types-and-how-many-data-types-are-in-java-language
What are data types and how many data types are in Java Language? | JanBask Training Community
November 17, 2019 - Primitive data types: These are predefined data types in Java. There are eight different primitive data types - Boolean, char, byte, short, int, long, float, double. These are reserved keywords.
🌐
Tutorialink
tutorialink.com › home › java › user defined data type
User Defined Data Type | JAVA | Tutorialink.com
User defined data types related variables allows us to store multiple values either of same type or different type or both. This is a data type whose variable can hold more than one value of dissimilar type, in java it is achieved using class concept.
🌐
IONOS
ionos.com › digital guide › websites › web development › java data types
What are the different data types in Java? - IONOS
December 18, 2024 - There are a total of eight different primitive data types in Java, which contain firmly defined value ranges. They can be divided into four cat­e­gories: logical data types, integral data types, floating-point data types and character data types.
🌐
DocStore
docstore.mik.ua › orelly › java-ent › jenut › ch10_07.htm
User-Defined Data Types (Java Enterprise in a Nutshell)
In addition to the basic data types already described, IDL supports user-defined data types, which are aggregations of these basic types. These complex data types include arrays, sequences, enumerations, and constructed data types you define yourself using structs and unions.
🌐
DataCamp
datacamp.com › doc › java › java-data-types
Java Data Types
Java is a statically typed language, meaning every variable must be declared with a data type before use. Java data types are categorized into two main groups: primitive data types and reference data types. Primitive data types are the most basic data types available in Java.
🌐
Scaler
scaler.com › home › topics › java › java data types
Java Data Types - Scaler Topics
June 1, 2023 - These are the data types that are not predefined but defined by the programmer according to the need for a particular task. For example: String, Arrays, class, etc. Let’s move further to discuss the primitive data types but first think about why there are so many data types available in the Java programming language. ... Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
🌐
Study.com
study.com › computer programming › programming languages
Overview of Data Types in Java | Study.com
November 7, 2024 - Non-primitive data types are data types that are not defined by the language, so you (the programmer) have to tell the compiler how to define and reference them. The three non-primitive data types in Java include the array, the class, and the interface. Identifiers are names used for identification. In Java, it can be the name of a class, method, or variable. Literals are representations of a data type that provide value to a variable. Abstract data types may have methods and operations, but those are not available to the outside.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › java tutorial › data types in java
Java Data Types: Guide to Primitive and Reference Types
November 7, 2023 - Developers can create their custom data types in Java using classes and interfaces. These user-defined data types allow for creating objects with specific attributes and behaviors, making Java a versatile and object-oriented programming language.
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Scribd
scribd.com › doc › 9823728 › Java-Chap5-User-Defined-Data-Types-Prof-Ananda-M-Ghosh
Java Chap5 User Defined Data Types ( Prof. Ananda M Ghosh.)
Java Chap5 User Defined Data Types ( Prof. Ananda M Ghosh.) - Free download as Word Doc (.doc), PDF File (.pdf), Text File (.txt) or read online for free. 5th chapter of a Book on Object Oriented Programming with Java -- An Introduction, useful for all beginners and Covers ICSE Computer Science ...
Rating: 4 ​ - ​ 1 votes
🌐
University of Alberta
sites.ualberta.ca › ~rosanna › books › PDSA › chapter1 › dataTypes.html
Data Types — Practices in Data Structures and Algorithms with Java
In addition, Java contains built-in reference data types such as arrays, Strings, and StringBuilders. Other data types must be imported, for example, ArrayList, HashMap, LinkedList, and Stack. All the data types that are not built-in are reference data types and follow the object-oriented paradigm. Pre-defined vs User-defined - Java comes with a large library of pre-defined data types but the programmer (user of Java) can also easily define new data types using Java’s class system.