DEV Community

yaswanth krishna
yaswanth krishna

Posted on

What is Variables and Datatype?

What is Variables?

Variables are containers for storing data values.

  1. String - stores text, such as "Hello". String values are surrounded by double quotes
  2. int - stores integers (whole numbers), without decimals, such as 123 or -123
  3. float - stores floating point numbers, with decimals, such as 19.99 or -19.99
  4. char - stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes
  5. boolean - stores values with two states: true or false

What is Datatypes ?

As explained in the previous chapter, a variable in Java must be a specified data type:

Data Type Description

byte Stores whole numbers from -128 to 127

int Stores whole numbers from -2,147,483,648 to 2,147,483,647

long Stores whole numbers from -9,223,372,036,854,775,808 to

       9,223,372,036,854,775,807
Enter fullscreen mode Exit fullscreen mode

float Stores fractional numbers. Sufficient for storing 6 to 7

       decimal digits
Enter fullscreen mode Exit fullscreen mode

double Stores fractional numbers. Sufficient for storing 15 to 16

       decimal digits
Enter fullscreen mode Exit fullscreen mode

boolean Stores true or false values

char Stores a single character/letter or ASCII values

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay