- 雙語版Java程序設(shè)計(jì)
- 何月順主編
- 380字
- 2018-12-27 20:14:12
3.1 Data Types Overview
Java is known as a strongly typed language. It means that Java is a language that will only accept specific values within specific variables or parameters. Some languages, such as JavaScript, are weakly typed languages. This means that you can readily store whatever you want into a variable. Here is an example of the difference between strongly typed and weakly typed languages:
JavaScript (weakly typed)(Java腳本)
1: var x; // Declare a variable
2: x = 1; // Legal
3: x = "Test"; // Legal
4: x = true; // Legal
Java (strongly typed)
1: int x; // Declare a variable of type int
2: x = 1; // Legal
3: x = "Test" // Compiler Error
4: x = true; // Compiler Error
In a weakly typed language, such as JavaScript, you simply declare a variable without assigning it a type. In a strongly typed language, such as Java, you must give a variable a type when you declare it. Once you’ve declared a variable to be that type, it will remain of that type definitely and will only accept values that are within that types range. You should note that this is one of the many differences between Java and JavaScript. Despite their names, they have very little to do with one another.
Java是一種強(qiáng)類型編程語言。當(dāng)聲明一個(gè)變量的時(shí)候,必須給出該變量的類型。一旦給定了類型,所賦予的值必須在相應(yīng)的精度內(nèi)。
Now that we know that Java is a strongly typed language, you can probably see how important it is to know what data types there are in Java. There are 9 data types in Java, 8 primitive types and a reference type. First, let’s look at primitive types and then we’ll move along to reference types.
Java是強(qiáng)制類型檢查的語言。Java中有9種數(shù)據(jù)類型,其中8種是基本類型,一種是引用類型。
- Hands-On Intelligent Agents with OpenAI Gym
- 計(jì)算機(jī)原理
- TestStand工業(yè)自動(dòng)化測(cè)試管理(典藏版)
- Hands-On Data Science with SQL Server 2017
- 大數(shù)據(jù)改變世界
- 流處理器研究與設(shè)計(jì)
- Embedded Programming with Modern C++ Cookbook
- 工業(yè)機(jī)器人操作與編程
- 影視后期編輯與合成
- Excel 2007技巧大全
- Mastering Game Development with Unreal Engine 4(Second Edition)
- 從零開始學(xué)PHP
- 零起點(diǎn)學(xué)西門子S7-200 PLC
- 基于RPA技術(shù)財(cái)務(wù)機(jī)器人的應(yīng)用與研究
- 青少年VEX IQ機(jī)器人實(shí)訓(xùn)課程(初級(jí))