answersLogoWhite

0

What is java primitive data types?

Updated: 8/11/2023
User Avatar

Wiki User

14y ago

Best Answer

Any data that is not stored as an object - like the integral data types (int, long, etc.), or boolean variables.

Any data that is not stored as an object - like the integral data types (int, long, etc.), or boolean variables.

Any data that is not stored as an object - like the integral data types (int, long, etc.), or boolean variables.

Any data that is not stored as an object - like the integral data types (int, long, etc.), or boolean variables.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

Basically any datatype that doesn't involve an object.

For example, int, float, double, etc., are primitive datatypes -- they are declared using the format Variable_type n = Value;, and, in general, they do not have any class functions which can be called - one cannot call n.function(), because it doesn't exist (there may be some exceptions to this, however). However, as a result, an access function is not necessary to access the variable's value -- println(n); returns value of n.

On the other hand, types such as Integer. String, etc. are not primitive datatypes, since they involve the creation and manipulation of objects. They are declared using the format Variable_type n = new Variable_type(Value);, and they tend to have some associated class functions. They do require access functions to access the variable's value -- println(n); in this case actually causes the execution of println(n.toString());, which by default returns the memory address of the object, unless otherwise overridden by the object's class definition. This access function depends from type to type.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago
  • byte: The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation.

  • short: The short data type is a 16-bit signed two's complement integer. It has a minimum value of -32,768 and a maximum value of 32,767 (inclusive). As with byte, the same guidelines apply: you can use a short to save memory in large arrays, in situations where the memory savings actually matters.

  • int: The int data type is a 32-bit signed two's complement integer. It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive). For integral values, this data type is generally the default choice unless there is a reason (like the above) to choose something else. This data type will most likely be large enough for the numbers your program will use, but if you need a wider range of values, use long instead.

  • long: The long data type is a 64-bit signed two's complement integer. It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive). Use this data type when you need a range of values wider than those provided by int.

  • float: The float data type is a single-precision 32-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in section 4.2.3of the Java Language Specification. As with the recommendations for byte and short, use a float (instead of double) if you need to save memory in large arrays of floating point numbers. This data type should never be used for precise values, such as currency. For that, you will need to use the java.math.BigDecimal class instead.Numbers and Strings covers BigDecimal and other useful classes provided by the Java platform.

  • double: The double data type is a double-precision 64-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in section4.2.3 of the Java Language Specification. For decimal values, this data type is generally the default choice. As mentioned above, this data type should never be used for precise values, such as currency.

  • boolean: The boolean data type has only two possible values: true and false. Use this data type for simple flags that track true/false conditions. This data type represents one bit of information, but its "size" isn't something that's precisely defined.

  • char: The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65,535 inclusive).

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

The primitive data types in java are: byte, short, int, long, float, double, boolean, char. This just means that these types of data are not stored as objects, but as values. For anything else (like a String), you must construct an object to store value.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Primitive data types represent atomic values and are built into java.

Java has 8 primitive data types.

Integer Data Types

byte (1 byte)

short (2 bytes)

int (4 bytes)

long (8 bytes)

Floating Data Types

float (4 bytes)

double (8 bytes)

Character Data Types

Char (2 bytes)

Logical Data Types

boolean (1 bit) (true/false)

Writer Hafiz A Khalique

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

There are two types of variables in Java:

• Primitives - A primitive variable can be one of eight types: char, boolean, byte, short, int, long, double, or float. Once a primitive has been declared, its primitive type can never change, although in most cases its value can change.

• Reference variables - A reference variable is used to refer to (or access) an object. A reference variable is declared to be of a specific type and that type can never be changed.

Primitive data types are used to hold data that is used for general calculations and other similar purposes.

Primitive data types are: int, byte, float etc

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

primitive means we r changing the order of the data for further information contact

rahulnegi8@ibibo.com

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

The 8 primitive data types are

byte, short, int, long, float, double, boolean and char

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Any data that is not stored as an object - like the integral data types (int, long, etc.), or boolean variables.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

That refers to primitive (or simple) data types - data that is not stored in objects. This includes boolean, int, long, float and double.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is java primitive data types?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Variables as object in java?

There are two main categories of variables in Java. They are primitive and non primitive. Primitive data types are the basic data types like int, float, char etc. These are not objects. The other non primitive data types are all types of Java Objects. Example: String, ArrayList etc.


How many simple data types are there?

There are a total of 8 simple or primitive data types in Java. They are:byteshortintfloatdoublebooleanlong andString


Primitive java data types?

The primitive data types in Java are:int: integer value from -232 to 232floatdoublelong: integer value from -264 to 264byte: integer value from -128 to 128char: charactershort: integer value from -32768 to 32768boolean: true or false valueString (not actually a primitive data type)


Is Java a true object oriented language?

since Java have primitive data types, I think its not pure OO


Do the primitive datatypes in java have objects?

No Primitive data types do not have objects. As of Java 1.5, all primitive types in Java have "wrapper" classes. These classes serve two purposes: # They keep all type-specific methods together in one place. # They allow primitive types to be used in situations which take advantage of generics (also introduced in Java 1.5).


What are primitive variables?

Primitive variables are variables that are not objects and carry primitive values like numbers, boolean etc. The primitive data types in java are:intbytefloatcharlongbooleanshortdouble


Why are there both primitive and object versions of integers doubles floats characters and booleans?

Primitive data types like int, float etc are available for us to perform primitive data type operations like addition, subtraction, comparison etc. But since Java is an object oriented language, there are many features in java where such primate data types cannot be used. Only objects can be used. So for using the features of such data types there also we have wrapper classes that would create objects for these primitive data types.


Java variable types and controls?

Java is a powerful language that gives us options to have data in different forms. We have several data types that we can use for our needs. The basic data types that java offers us are termed as Primitive Data Types. Though all programming languages have varied data types java offers us with a variety of data types that are much powerful and simplified to use when compared to other languages.The Java programming language is strongly-typed, which means that all variables must first be declared before they can be used. This involves stating the variable's type and name.int age = 10;The above statement tells the java compiler that a field named "age" which holds numeric data and having an initial value of 10 is declared. A variable's data type determines the values it may contain, plus the operations that may be performed on it. In addition to int, the Java programming language supports seven other primitive data types. A primitive type is predefined by the language and is named by a reserved keyword. Primitive values do not share state with other primitive values. The eight primitive data types supported by the Java programming language are:byte, short, int, long, float, double, char and boolean


What are the Different types of data type?

Java Data TypesJava is a powerful language that gives us options to have data in different forms. We have several data types that we can use for our needs. The basic data types that java offers us are termed as Primitive Data Types. Though all programming languages have varied data types java offers us with a variety of data types that are much powerful and simplified to use when compared to other languages.The Java programming language is strongly-typed, which means that all variables must first be declared before they can be used. This involves stating the variable's type and name.int age = 10;The above statement tells the java compiler that a field named "age" which holds numeric data and having an initial value of 10 is declared. A variable's data type determines the values it may contain, plus the operations that may be performed on it. In addition to int, the Java programming language supports seven other primitive data types. A primitive type is predefined by the language and is named by a reserved keyword. Primitive values do not share state with other primitive values. The eight primitive data types supported by the Java programming language are: byte, short, int, float, double, long, char and boolean


What are fundamental data types in java?

Assuming by "fundamental" you mean the primitive data types: boolean, byte, char, short, int, long, float, and double


Is string is primitive or user defined data type?

String - is primitive data typestring - is user defined data type


Why java is purely object oriented programming language?

It is said that Java is not purely object-oriented, because of its handling of primitive data types. The reason for this is for efficiency.