碧玉是什么玉| 什么叫通勤| 喉咙痛不能吃什么东西| 腿肿脚肿是什么原因引起的| 羊肉和什么相克| 猫为什么吃老鼠| 为什么不能天天喝豆浆| 湿寒吃什么中成药| 梦见蜜蜂是什么预兆| 坚强后盾是什么意思| 乙肝表面抗原250是什么意思| 白痰多是什么原因| 拘留是什么意思| 代偿是什么意思| 吃完桃子不能吃什么| 老觉得饿是什么原因| 胃疼吃什么药管用| nyc是什么牌子| 京东pop是什么意思| 做梦笑醒了有什么征兆| 冰释前嫌什么意思| 颈椎吃什么药| 取保候审是什么意思还会判刑吗| 八月初三是什么星座| 吃什么可以补肾| 囧途什么意思| 为什么拉绿色的屎| 生物科技是做什么的| 黄体期什么意思| 蓝莓有什么功效与作用| 眼睛散光是什么症状| 什么是介入手术| 自我安慰是什么意思| doosan挖掘机是什么牌子| 住院号是什么| 吃什么补钾最快最好| 少年白头发是什么原因| 喜悦之情溢于言表什么意思| 猫最喜欢吃什么| 什么鱼炖汤好喝又营养| 风湿属于什么科| 种马是什么意思| 热感冒吃什么药好| lime是什么颜色| 胃穿孔是什么原因引起的| 生门是什么意思| 29度穿什么衣服合适| 牙龈肿吃什么药| 中耳炎是什么| who是什么意思| 什么的梨花| 反胃是什么原因引起的| 干咳吃什么药止咳效果好| 做梦梦到掉牙齿是什么意思| 萤火虫为什么发光| 招蚊子咬是什么原因| 淋巴细胞绝对值偏高是什么意思| 反应性细胞改变炎症是什么意思| 鬼冢虎为什么很少人穿| hrv什么意思| 什么是鸡胸病症状图片| 排卵日是什么意思| 思伤脾是什么意思| 手机买什么好| 蛋白粉适合什么人吃| 结核是什么病| 硒是什么元素| 残疾证有什么好处| 乙肝看什么科| gmv是什么意思| 梦见钱包丢了是什么意思| 灰什么丧什么| 4月1日是什么星座| 精神衰弱吃什么能改善| 917是什么星座| cpr是什么意思| pppd是什么意思| 体检前一天晚上吃什么| 淋巴细胞比率偏高是什么原因| 闻字五行属什么| 胸闷气短咳嗽是什么原因引起的| 什么是抗氧化| 副教授是什么级别| 麻黄是什么| 怀孕吃什么水果好| 心绞痛挂什么科| 消化不好吃什么| 女人代谢慢吃什么效果最快| 女人出轨有什么表现| 什么是相位| b超能检查出什么| 头皮痒挂什么科| 童子是什么| 肛门痒是什么原因| pocky是什么意思| 拔完智齿后需要注意什么| 风疹病毒是什么| 五心烦热吃什么药| 哈西奈德溶液治什么病| ntc是什么| leu是什么氨基酸| 怪力乱神是什么意思| 信阳毛尖是什么茶| 手指甲上有竖纹是什么原因| 上火了吃什么食物降火| 泡脚有什么好处| 老人说胡话是什么征兆| 无创低风险是什么意思| 尿频是什么原因| 头出汗多至头发湿透是什么原因| 尿失禁是什么意思| 猎奇是什么意思| 心悸心慌吃什么药| 脑内小缺血灶是什么意思| 洋酒是什么酒| 十一月份属于什么星座| 大姨妈延迟是什么原因| 月嫂下户是什么意思| 骨折和骨裂有什么区别| 豆柏是什么| 右手中指发麻是什么原因| 硕士研究生是什么意思| 2000年为什么叫千禧年| 梦见买棺材是什么征兆| 三个耳读什么| 消化不良用什么药| 维生素b9是什么| 脾虚湿气重吃什么药| 男生适合学什么专业| 什么的旋律| 何以笙箫默是什么意思| 9月出生的是什么星座| 我要控制我自己是什么歌| 骨折吃什么恢复快| 免疫球蛋白低说明什么| 388是什么意思| 什么字属金| 还愿有什么讲究| 小蜗牛吃什么| 频发室性早搏吃什么药| 传说中的狮身人面像叫什么名字| 葡萄糖阴性什么意思| 什么是着相| 成王败寇什么意思| 男属兔和什么属相最配| 是什么牌子的衣服| 羊驼为什么吐口水| 720是什么意思| 莴笋什么时候种植| 断掌什么意思| 频繁放屁是什么原因| 藕带是什么| 结婚27年是什么婚| 孩子肚子疼是什么原因| 为什么玉镯不能戴左手| 金蝉花是什么| 梦见自己拉屎是什么意思| 绝经是什么意思| 免疫球蛋白e高说明什么| 五福是什么生肖| 铁剂不能和什么一起吃| 侧柏是什么植物| 五行大林木是什么意思| 屈光是什么意思| 上车饺子下车面什么意思| bac是什么意思| ads是什么意思| 什么心丧气| 喉咙痛有痰吃什么药| 什么病才查凝血四项呢| 肿瘤手术后吃什么好| 贤良淑德后半句是什么| 什么叫相向而行| 聚酯纤维是什么材质| 夜间睡觉出汗是什么原因| 什么七什么八| 什么是更年期| 头陀是什么意思| 摩羯座女和什么座最配| 去侍庙有什么禁忌| 女人下面有异味是什么原因| 拉肚子吃什么药管用| ctu是什么意思| 害羞的近义词是什么| 国窖1573是什么香型| 什么东西不导电| 死皮是什么| 桃符指的是什么| 骨密度增高是什么意思| 未见胎芽是什么意思| 青蛙靠什么呼吸| 舌头胖大是什么原因| 孕妇建档是什么意思| 耳聋吃什么药| 耳屎多是什么原因| 有什么好用的vpn| 口腔异味挂什么科| 白酒不能和什么一起吃| 阔以是什么意思| 小月子是什么意思| 卡号是什么| 马拉松起源与什么有关| 吃什么可以健脾养胃| 2月20是什么星座| 青云志是什么意思| 李五行属什么| 孩子高低肩有什么好办法纠正| 等闲变却故人心却道故人心易变什么意思| 公卿是什么意思| 九九年属什么| 流汗多是什么原因| 看什么看| 吕布的武器叫什么| 迎风流泪是什么原因| 赛马不相马什么意思| 风热感冒吃什么药最好| 持续高烧不退是什么原因| 梦见大胖小子是什么意思| 两肺纹理增多是什么意思| 夏至节气吃什么| 三点水念什么| 挂号特需是什么意思| 血红蛋白浓度偏高是什么意思| 淡定从容是什么意思| 树膏皮是什么皮| 降血糖的草都有什么草| 黑色素缺失吃什么补充最快| 火把节什么时候| 嗓子嘶哑吃什么药| 砥砺前行什么意思| 1968年什么时候退休| 内衣为什么会发霉| 德巴金是什么药| 全程c反应蛋白高说明什么| 文曲星下凡是什么意思| 什么鲜花填动词| 什么牛奶好| 狐臭是什么味| 地下恋是什么意思| 三七粉什么人不适合吃| 火烧火燎是什么意思| 心境情感障碍是什么病| 肉苁蓉有什么功能| 2049年是什么年| 吐痰带血是什么原因| 脑出血什么原因引起的| 三乙醇胺是什么东西| 男生叫你姑娘什么意思| 胎盘中药叫什么| 长期拉肚子是什么原因| 为什么心率过快| 普洱茶适合什么季节喝| 玉谷叶是什么植物| 黛力新主治什么病| 腹泻输液用什么药| 尿毒症有些什么症状| 猪血和鸭血有什么区别| 豆瓣是什么软件| 子宫动脉阻力高是什么引起的| 谭咏麟属什么生肖| 孕妇可以吃什么| 火烈鸟为什么是红色的| 乳头痒什么原因| 新加坡用什么货币| 百度
Documentation

The Java™ Tutorials
Primitive Data Types
Trail: Learning the Java Language
Lesson: Language Basics
Section: Variables

雨花茶是什么茶

百度   现代通信技术的发达,网络、电脑、微信、私媒体时代的信息爆炸,多数中国人每天都在疯狂地陶醉/享用在史诗般信息混战/大餐。

The Java programming language is statically-typed, which means that all variables must first be declared before they can be used. This involves stating the variable's type and name, as you've already seen:

int gear = 1;

Doing so tells your program that a field named "gear" exists, holds numerical data, and has an initial value of "1". A variable's data type determines the values it may contain, plus the operations that may be performed on it. In addition to int, the Java programming language supports seven other primitive data types. A primitive type is predefined by the language and is named by a reserved keyword. Primitive values do not share state with other primitive values. The eight primitive data types supported by the Java programming language are:

In addition to the eight primitive data types listed above, the Java programming language also provides special support for character strings via the java.lang.String class. Enclosing your character string within double quotes will automatically create a new String object; for example, String s = "this is a string";. String objects are immutable, which means that once created, their values cannot be changed. The String class is not technically a primitive data type, but considering the special support given to it by the language, you'll probably tend to think of it as such. You'll learn more about the String class in Simple Data Objects

Default Values

It's not always necessary to assign a value when a field is declared. Fields that are declared but not initialized will be set to a reasonable default by the compiler. Generally speaking, this default will be zero or null, depending on the data type. Relying on such default values, however, is generally considered bad programming style.

The following chart summarizes the default values for the above data types.

Data Type Default Value (for fields)
byte 0
short 0
int 0
long 0L
float 0.0f
double 0.0d
char '\u0000'
String (or any object)   null
boolean false

Local variables are slightly different; the compiler never assigns a default value to an uninitialized local variable. If you cannot initialize your local variable where it is declared, make sure to assign it a value before you attempt to use it. Accessing an uninitialized local variable will result in a compile-time error.

Literals

You may have noticed that the new keyword isn't used when initializing a variable of a primitive type. Primitive types are special data types built into the language; they are not objects created from a class. A literal is the source code representation of a fixed value; literals are represented directly in your code without requiring computation. As shown below, it's possible to assign a literal to a variable of a primitive type:

boolean result = true;
char capitalC = 'C';
byte b = 100;
short s = 10000;
int i = 100000;

Integer Literals

An integer literal is of type long if it ends with the letter L or l; otherwise it is of type int. It is recommended that you use the upper case letter L because the lower case letter l is hard to distinguish from the digit 1.

Values of the integral types byte, short, int, and long can be created from int literals. Values of type long that exceed the range of int can be created from long literals. Integer literals can be expressed by these number systems:

For general-purpose programming, the decimal system is likely to be the only number system you'll ever use. However, if you need to use another number system, the following example shows the correct syntax. The prefix 0x indicates hexadecimal and 0b indicates binary:

// The number 26, in decimal
int decVal = 26;
//  The number 26, in hexadecimal
int hexVal = 0x1a;
// The number 26, in binary
int binVal = 0b11010;

Floating-Point Literals

A floating-point literal is of type float if it ends with the letter F or f; otherwise its type is double and it can optionally end with the letter D or d.

The floating point types (float and double) can also be expressed using E or e (for scientific notation), F or f (32-bit float literal) and D or d (64-bit double literal; this is the default and by convention is omitted).

double d1 = 123.4;
// same value as d1, but in scientific notation
double d2 = 1.234e2;
float f1  = 123.4f;

Character and String Literals

Literals of types char and String may contain any Unicode (UTF-16) characters. If your editor and file system allow it, you can use such characters directly in your code. If not, you can use a "Unicode escape" such as '\u0108' (capital C with circumflex), or "S\u00ED Se\u00F1or" (Sí Señor in Spanish). Always use 'single quotes' for char literals and "double quotes" for String literals. Unicode escape sequences may be used elsewhere in a program (such as in field names, for example), not just in char or String literals.

The Java programming language also supports a few special escape sequences for char and String literals: \b (backspace), \t (tab), \n (line feed), \f (form feed), \r (carriage return), \" (double quote), \' (single quote), and \\ (backslash).

There's also a special null literal that can be used as a value for any reference type. null may be assigned to any variable, except variables of primitive types. There's little you can do with a null value beyond testing for its presence. Therefore, null is often used in programs as a marker to indicate that some object is unavailable.

Finally, there's also a special kind of literal called a class literal, formed by taking a type name and appending ".class"; for example, String.class. This refers to the object (of type Class) that represents the type itself.

Using Underscore Characters in Numeric Literals

In Java SE 7 and later, any number of underscore characters (_) can appear anywhere between digits in a numerical literal. This feature enables you, for example. to separate groups of digits in numeric literals, which can improve the readability of your code.

For instance, if your code contains numbers with many digits, you can use an underscore character to separate digits in groups of three, similar to how you would use a punctuation mark like a comma, or a space, as a separator.

The following example shows other ways you can use the underscore in numeric literals:

long creditCardNumber = 1234_5678_9012_3456L;
long socialSecurityNumber = 999_99_9999L;
float pi =  3.14_15F;
long hexBytes = 0xFF_EC_DE_5E;
long hexWords = 0xCAFE_BABE;
long maxLong = 0x7fff_ffff_ffff_ffffL;
byte nybbles = 0b0010_0101;
long bytes = 0b11010010_01101001_10010100_10010010;

You can place underscores only between digits; you cannot place underscores in the following places:

The following examples demonstrate valid and invalid underscore placements (which are highlighted) in numeric literals:

// Invalid: cannot put underscores
// adjacent to a decimal point
float pi1 = 3_.1415F;
// Invalid: cannot put underscores 
// adjacent to a decimal point
float pi2 = 3._1415F;
// Invalid: cannot put underscores 
// prior to an L suffix
long socialSecurityNumber1 = 999_99_9999_L;

// OK (decimal literal)
int x1 = 5_2;
// Invalid: cannot put underscores
// At the end of a literal
int x2 = 52_;
// OK (decimal literal)
int x3 = 5_______2;

// Invalid: cannot put underscores
// in the 0x radix prefix
int x4 = 0_x52;
// Invalid: cannot put underscores
// at the beginning of a number
int x5 = 0x_52;
// OK (hexadecimal literal)
int x6 = 0x5_2; 
// Invalid: cannot put underscores
// at the end of a number
int x7 = 0x52_;

Previous page: Variables
Next page: Arrays
蜂胶是什么东西 两肺散在小结节是什么意思 svip是什么意思 神经酸是什么 为什么会缺乏维生素d
梦见蛇预示着什么 主动脉硬化是什么意思 手震颤是什么原因引起的 回民为什么不吃猪肉 覅是什么意思
做什么好赚钱 exp是什么日期 鸡胗是什么器官 千千结是什么意思 肝胆湿热用什么药
bid是什么意思啊 来姨妈能吃什么水果 绿茶不能和什么一起吃 11月份是什么星座 hov是什么意思
什么减肥药最安全hcv7jop6ns0r.cn 头发黄是什么原因hcv9jop1ns8r.cn 精液的主要成分是什么hcv9jop3ns7r.cn 邪火是什么意思hcv8jop0ns0r.cn 泌尿系统感染挂什么科hcv9jop4ns3r.cn
什么是幻听hcv8jop3ns6r.cn 早上打嗝是什么原因呢travellingsim.com 颈椎痛看什么科hcv9jop4ns8r.cn 慢慢张开你的眼睛是什么歌的歌词hcv8jop3ns0r.cn 淋巴结肿大看什么科室最好adwl56.com
借鸡生蛋是什么意思hcv9jop3ns6r.cn 得艾滋病的人有什么症状weuuu.com 检查胃挂什么科hcv8jop8ns4r.cn 七年是什么婚hcv9jop4ns5r.cn 总胆汁酸是什么意思hcv9jop3ns0r.cn
岁月从不败美人什么意思hcv9jop1ns9r.cn 得糖尿病的原因是什么hcv8jop6ns4r.cn 6月24日是什么日子hcv8jop3ns2r.cn 5月3日什么星座hcv8jop5ns7r.cn 芭比q是什么意思hcv9jop7ns2r.cn
百度