Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are Java's primitive types? [duplicate]

What are primitive type in Java?

What is the difference between a primitive type and a reference type?

How many primitive types does Java have, and what are they?

like image 412
Android Girl Avatar asked May 03 '12 11:05

Android Girl


People also ask

What are Java's primitive types?

Primitive Data Types. The eight primitives defined in Java are int, byte, short, long, float, double, boolean and char. These aren't considered objects and represent raw values. They're stored directly on the stack (check out this article for more information about memory management in Java).

What are the 4 primitive data types?

Data types are divided into two groups: Primitive data types - includes byte , short , int , long , float , double , boolean and char. Non-primitive data types - such as String , Arrays and Classes (you will learn more about these in a later chapter)


1 Answers

In Java, every variable has a type declared in the source code. There are two kinds of types: reference types and primitive types. Reference types are references to objects. Primitive types directly contain values. There are 8 primitive types:

  • byte
  • short
  • int
  • long
  • char
  • float
  • double
  • boolean
like image 65
Michael Borgwardt Avatar answered Sep 17 '22 14:09

Michael Borgwardt