Primitive java data types list with examples w3schools
Primitive java data types list with examples w3schools
I'm happy to respond in English for you! Here's a list of primitive Java data types with examples, courtesy of W3Schools:
1. Byte
The byte data type is an 8-bit signed integer. It has a minimum value of -128 and a maximum value of 127.
Example:
byte myByte = 50;
2. Short
The short data type is a 16-bit signed integer. It has a minimum value of -32,768 and a maximum value of 32,767.
Example:
short myShort = 1000;
3. Int
The int data type is a 32-bit signed integer. It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647.
Example:
int myInt = 500000;
4. Long
The long data type is a 64-bit signed 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.
Example:
long myLong = 5000000000L;
5. Float
The float data type is a single-precision floating-point number. It has a minimum value of approximately 1.4E-45 and a maximum value of approximately 3.4E+38.
Example:
float myFloat = 123.456f;
6. Double
The double data type is a double-precision floating-point number. It has a minimum value of approximately 4.9E-324 and a maximum value of approximately 1.8E+308.
Example:
double myDouble = 123.456;
7. Boolean
The boolean data type represents a logical true or false value.
Example:
boolean myBoolean = true;
8. Char
The char data type is an unsigned character. It has a minimum value of 'u0000' (the null character) and a maximum value of 'uffff'.
Example:
char myChar = 'A';
In summary, Java primitive data types are:
Eight-bit signed integer: byte Sixteen-bit signed integer: short Thirty-two-bit signed integer: int Sixty-four-bit signed integer: long Single-precision floating-point number: float Double-precision floating-point number: double Logical true or false value: boolean Unsigned character: charThese data types are used extensively in Java programming to store and manipulate values.
Primitive java data types list with examples geeksforgeeks
I'm happy to help you with that! Here's a list of primitive Java data types along with examples:
1. boolean: Represents true or false values.
Example:
boolean isAdmin = true; // or false
2. byte: An 8-bit signed integer.
Example:
byte myAge = 25;
3. char: A single character represented as a 16-bit unsigned integer.
Example:
char myInitial = 'J';
4. short: A 16-bit signed integer.
Example:
short myScore = 1000;
5. int: A 32-bit signed integer.
Example:
int myID = 123456;
6. long: A 64-bit signed integer.
Example:
long myPhoneNumber = 1234567890L; // note the L at the end
7. float: A single-precision floating-point number.
Example:
float myGPA = 3.5f; // note the f at the end
8. double: A double-precision floating-point number.
Example:
double myHeight = 6.2;
9. void: The absence of a value or type, often used as a return type for methods that don't return anything.
Example:
void printHello() {
System.out.println("Hello!");
}
These are the eight primitive data types in Java, along with some example usage. Keep in mind that Java also has several non-primitive data types, such as String
, Array
, and Class
, which can be used to create more complex data structures.
I hope this helps! Let me know if you have any other questions.