Java is a common type of several types of range description, char variables can not be stored in a Chinese character

Source: Internet
Author: User

Package Com.yuan.test;public class Autogrew {public static void main (string[] args) {//The constant that holds the maximum value for short, the maximum value is 215-1. (32 767)//The constant that holds the minimum value of short, the minimum value is-215.     ( -32 768) short s1=11278;     S1+=1;     s1=s1+1;//error will automatically be converted to int type System.out.println (S1);      The value is a constant of 2 31 square-1, which represents the maximum value that the int type can represent.     The value is a constant of 2 31, which represents the minimum value that the int type can represent. A constant that holds the desired maximum value of the byte type, which is 2 7 square-1. (127)//A constant that holds the minimum value of the byte type, that is, 2 7 times. (-128)}}

ForShort S1 = 1; S1 = s1 + 1;BecauseS1+1Operation, you willTypes of auto-lifted expressions, so the result isInt
Type, and then assign a value toShortTypeS1When The compiler will report errors that require a cast type
due to += is java processing, so you can Span style= "FONT-SIZE:11PT; Color:rgb (0, 0, 255); " > correctly compiled

2CharA Chinese character can be stored in a type variable?Why?
CharType variable is used toStoreUnicodeCodingof the characters,UnicodeThe encoded character set contains the kanji, so,
Char
char Supplementary note:
char note: The latter part of the answer, although not in the positive answer, but, in order to show their knowledge and performance of their own to
A thorough understanding of the problem, can answer some relevant knowledge, do sparing, liker.

There are several types of Java common Type range description, char variable can not be stored in a Chinese character

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.