Data Types and Variables in Java


Java has several data types to represent numbers, characters, and booleans. Variables are used to store data values.

Source Code

int myNum = 5;               // Integer (whole number)
float myFloatNum = 5.99f;    // Floating point number
char myLetter = 'D';         // Character
boolean myBool = true;       // Boolean
String myText = "Hello";     // String

Choose the appropriate data type for your variables based on the data you need to store.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments