java输出变量数据类型_了解Java变量和数据类型

本文介绍了Java变量和数据类型的基础知识,包括变量的作用、命名规范、如何使用以及Java的数据类型,如字符串、整型、布尔型等。通过示例说明了如何存储和操作数据,强调理解变量和数据类型对于Java编程的重要性。
摘要由CSDN通过智能技术生成

java输出变量数据类型

At SitePoint we’re always looking to expand the range of topics we cover. Lately, we’ve set our sights on exploring the world of Java. If you’re a strong Java developer who wants to contribute to our coverage, get in touch with a few ideas for articles you’d like to write.

在SitePoint,我们一直在寻求扩大我们涵盖的主题范围。 最近,我们将目光投向了探索Java的世界。 如果您是一名强大的Java开发人员,想为我们的报道做出贡献,请与您想写的文章的一些想法保持联系

Java variables enable programmers to store single data points, bits of information, for later use. For efficiency in later use, Java variables have types. Those types are referred to as data types because they allow us to store different types of data respectively for convenience and predictability. It’s necessary for any Java programmer to understand the basics of variables and data types in Java before moving on to more advanced topics.

Java变量使程序员能够存储单个数据点和信息位,以备后用。 为了提高以后使用的效率,Java变量具有类型。 这些类型被称为数据类型,因为它们使我们分别为了方便和可预测性而存储不同类型的数据。 任何Java程序员都必须先了解Java中变量和数据类型的基础,然后再转向更高级的主题。

To illustrate how Java variables work, let’s imagine a photo sharing application. The app would store a whole bunch of information about the state of our application and the photos its users share: the number of users, the number of photos shared, and the total number of comments shared. That data has to be stored in order for us to manipulate and display them to our users when necessary. Enter Java variables.

为了说明Java变量如何工作,让我们想象一个照片共享应用程序。 该应用程序将存储有关我们的应用程序状态及其用户共享的照片的所有信息:用户数量,共享的照片数量以及共享的评论总数。 必须存储该数据,以便我们在必要时进行操作并将其显示给我们的用户。 输入Java变量。

Java变量 (Java Variables)

Variables can hold data and that data can be changed over the lifetime of our program. A variable must have a type, a name, and be provided some sort of data to hold. The most widely used type of data in Java is the character string, represented by Java’s String class. A string, such as “SitePoint” is simply an instance of the String class.

变量可以保存数据,并且可以在程序的生命周期内更改数据。 变量必须具有类型,名称,并提供某种数据来保存。 Java中使用最广泛的数据类型是字符串,由Java的String类表示。 诸如“ SitePoint”之类的String只是String类的一个实例。

命名变量 (Naming Variables)

There are a few rules you must follow and a few you should. Java’s variable names are case senstive and can be an unlimited number of letters and numbers. However, variable names must start with a letter, underscore character _ , or a dollar sign $.

必须遵循一些规则,而您应该遵循一些规则。 Java的变量名区分大小写,并且可以是字母和数字的任意数量。 但是,变量名必须以字母,下划线字符_或美元符号$开头。

When creating variables in Java, it is best to follow the convention of using numbers and full words that are descriptive of the purpose of the variable while avoiding use of the underscore character and dollar sign. Finally, variables should be in lower camel case, a popular programming convention that dictates that the first letter of the first word should be in lower case and the following words should be capitalized.

在Java中创建变量时,最好遵循使用描述变量目的的数字和完整单词的约定,同时避免使用下划线字符和美元符号。 最后,变量应使用小写驼峰,这是一种流行的编程约定,规定第一个单词的第一个字母应小写,随后的单词应大写。

beans

使用变量

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值