- 雙語版Java程序設(shè)計(jì)
- 何月順主編
- 360字
- 2018-12-27 20:14:13
3.5 Summary
That’s it for data types in Java. Just remember that Java is a strongly typed language. So much so, in fact, that you’ll learn these data types in a big hurry if you use Java very much at all. For those of you coming from a C++ type background, you’ll probably notice right away that Java is even more strongly typed than C++. For example, no more assigning 1 to a boolean variable. In Java, booleans are true or false - nothing else. Most of the information here is probably review/common sense if you’ve done any sort of programming at all. The most important thing for you to get out of this is to remember that Java is strongly typed.
As you will already know a variable is a value in a program which can be changed, this value is then used in some way by the program. For example, if a program were to ask the user for their age then print out how old they would be in 10 years time the program would store the age as a variable and then add 10 to it.
In Java variables are declared with the following syntax(語法):
data_type variable_name;
The data_type can be from the simple types or from user defined types (which will be covered in later tutorials).
The simple types are:
byte, short, int and long. All these types hold integer numbers of varying minimum and maximum sizes.
float and double which hold floating point numbers, again with different minimum and maximum values.
char is used to hold the value of characters.
boolean variables are either true or false.
byte, short, int和long,這些類型都存儲(chǔ)具有不同范圍的最大值和最小值的整數(shù)。
float和double存儲(chǔ)浮點(diǎn)數(shù)字,同樣具有不同的最小值和最大值。
char用來存儲(chǔ)字符的值。
boolean變量為真值或假值。
- Java編程全能詞典
- Unreal Engine:Game Development from A to Z
- 過程控制工程及仿真
- Dreamweaver 8中文版商業(yè)案例精粹
- Apache Hive Essentials
- 計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)基礎(chǔ)
- DevOps:Continuous Delivery,Integration,and Deployment with DevOps
- 數(shù)據(jù)通信與計(jì)算機(jī)網(wǎng)絡(luò)
- Splunk Operational Intelligence Cookbook
- 高維聚類知識(shí)發(fā)現(xiàn)關(guān)鍵技術(shù)研究及應(yīng)用
- Linux嵌入式系統(tǒng)開發(fā)
- Mastering Exploratory Analysis with pandas
- 三菱FX/Q系列PLC工程實(shí)例詳解
- 傳感器原理與工程應(yīng)用
- Generative Adversarial Networks Projects