In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail about the logic class, parameter class and character class in java language. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Logic class, parameter class, and character class
Basic data types of Java programming language
There are eight basic data types in the Java programming language, which are:
Boolean 、 byte 、 short 、 int 、 long 、 float 、 double 、 char
These eight basic data types can be customarily divided into the following four major types:
Logical type: boolean
Integer types: byte, short, int, long
Character type: char
Floating point type: float, double
Logical type
Constant: true,false.
Variables: use the keyword boolean to declare logical variables, which can also be assigned to initial values when declared
For example: boolean XJ ok.true, close = false
Parameter type
1.int type
Constants: 123 cd6000 (decimal), 077 (octal), 0x3ABC (hexadecimal).
Variables: use the keyword int to declare int variables, which can also be assigned to initial values when declared
For example: int x = 12, average = 9898 Jiafei
For int variables, memory is allocated to 4 bytes (byte), accounting for 32 bits. Int values range from positive 2 to the 31st power minus one to the negative 2 to the 31st power.
2. Byte type
Constant: there is no representation of byte-type constants in Java, but int-type constants in a certain range can be assigned to byte-type variables.
Variables: use the keyword byte to declare byte variables
For example: byte x =-12 century tomography 28, beautiful 9; (a variable made up of a Chinese character and a number, and is not responsible for him)
For byte memory, 1 byte is allocated, accounting for 8 bits. The range of values for byte is Int, which ranges from positive 2 to the 7th power of 2 minus 1 to negative 2 to 7.
3. Short type
Constant: similar to the byte type, there is no representation of an int constant in Java, but an int constant within a certain range can be assigned to a binary variable.
Variables: use the keyword short to declare a variant variable
For example: short Xerox 1214
For variant variables, memory is allocated to 2 bytes, accounting for 16 bits. The range of values for Short is Int, which ranges from positive 2 to the 15th power of 2 minus 1 to negative 2 to 15.
4. Long type
Constants: long constants are represented by the suffix L, such as 108L (decimal), 07123L (octal), 0x3ABCL (hexadecimal).
Variables: use the keyword long to declare long variables
For example: long width=12L,height=2005L,length
For long variables, memory is allocated to 8 bytes, accounting for 64 bits. The range of values for Long is Int, which ranges from the 63rd power of positive 2 minus one to the 63rd power of negative 2.
Character type
1. Constant: a character in the Unicode table expanded in single quotation marks, which is a character in the Unicode table expanded in single quotation marks.
two。 Variables: use the keyword char to declare chartype variables
For example: char ch='A',home=' home, handsome=' cool
For char variables, memory is allocated to 2 bytes, accounting for 16 bits. The range of values for Char is Int, which ranges from positive 2 to the 15th power of 2 minus 1 to negative 2 to 15.
3. Transfer character constant: if some characters (such as carriage return) cannot be entered into a string or program through the keyboard, you need to use the transfer character constant.
For example:\ n (newline),\ b (backspace),\ t (horizontal tabulation),\'(single quotation mark),\ "(double quotation mark),\ (backslash), etc.
4. To observe the sequential position of a character in the Unicode table, you can use int to display the transformation, such as (int)'a'or int paired characters'.
5. If you want to get a character in the corresponding position in the Unicode table represented by a number between 0,65536, you must use the char type to display the conversion.
Import java.util.Scanner
Public class Demo5 {* declare a class that is the same as the source file
Public static void main (String args []) {* makes him the main class
/ / char ch2= 'country', ch3 = 'Qing'; * define chartype variables
/ / System.out.println (position of "ch2+" in the unicode table: "+ (int) ch2); * output the corresponding position of the two characters in the unicode table and convert the characters strongly to int
/ / System.out.println (location of "ch3+" in unicode table: "+ (int) ch3)
/ / int p1 = 969, p2 = 12353; * characters corresponding to 969 and 12353
/ / System.out.println (the character in the position "+ p1+" is: "+ (char) p1); * p1 is strongly converted to char
/ / System.out.println (the character in the position "+ p2+" is: "+ (char) p2)
/ / float weight = 82.5f
/ / int height = 176
/ / double d = (height-100) / weight
/ / System.out.println ("weight:" + weight)
/ / System.out.println ("height:" + height)
/ / System.out.println ("coefficient:" + d)
/ / Scanner reader=new Scanner (System.in)
/ / System.out.println ("please input int")
/ / int I = reader.nextInt ()
/ / System.out.println ("you input:" + I)
Int I = 12
System.out.printf (the value of "I is:% d", I)
}
}
Compiled through
This is the end of this article on "what are logic classes, parameter classes and character classes in java language?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.
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.