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
       9,223,372,036,854,775,807
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
       decimal digits
decimal digits

Enter fullscreen mode Exit fullscreen mode

double Stores fractional numbers. Sufficient for storing 15 to 16

decimal digits
       decimal digits
decimal digits

Enter fullscreen mode Exit fullscreen mode

boolean Stores true or false values

char Stores a single character/letter or ASCII values

原文链接:What is Variables and Datatype?

© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享
love understands love; it needs no talk.
相爱的心息息相通,无需用言语倾诉
评论 抢沙发

请登录后发表评论

    暂无评论内容