In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the JAVASE data types, variable definition and the use of sample analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
A data type
Java is a strongly typed language, so data types should be distinguished and cannot be converted to each other after definition.
Two big data types of Java:
Built-in data type
Reference data type
The Java language provides eight basic types.
Two code examples:
Public class Test {
Static boolean bool
Static byte by
Static char ch
Static double d
Static float f
Static int i
Static long l
Static short sh
Static String str
Public static void main (String [] args) {
System.out.println ("Bool:" + bool)
System.out.println ("Byte:" + by)
System.out.println ("Character:" + ch)
System.out.println ("Double:" + d)
System.out.println ("Float:" + f)
System.out.println ("Integer:" + I)
System.out.println ("Long:" + l)
System.out.println ("Short:" + sh)
System.out.println ("String:" + str)
}
}
1234567891011121314151617181920212223
Note that the long and float definitions are defined with L and f, respectively, for example:
Long a = 100000L
Float b = 234.5f
twelve
In fact, when defining double, we also need to write d, but in most cases we omit it.
Three reference types
In Java, a variable of a reference type is very similar to a pointer to Cstroke +. The reference type points to an object, and the variable pointing to the object is the reference variable. These variables are specified as a specific type when declared, such as Employee, Puppy, and so on. Once a variable is declared, the type cannot be changed.
Objects and arrays are reference data types. The default value for all reference types is null. A reference variable can be used to reference any type that is compatible with it.
Definition and use of four variables
Variable definition method: data type variable name = variable value; which is better to treat birthmarks in Zhengzhou http://www.zzzykdmlk.com/
For example:
Int age = 18
Use: direct output, or do operations, get, determine and compare. (personal understanding, it will improve the use after in-depth study.)
If (age > 17) {
Age=age+1
System.out.println (age)
}
1234567
Naming rules of five variables
The first letter of the variable name must be the letter (amurz Amurz), the underscore (_), or the dollar sign ($). Avoid using spaces, Chinese characters, and keywords. Try to use hump nomenclature. Variable names are as meaningful as possible to avoid meaningless names such as: int a
Thank you for reading this article carefully. I hope the article "sample Analysis of data types, variable Definitions and uses in JAVASE" shared by the editor will be helpful to you. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.