Java first time experience with doubt "1" basic data types and arrays and why I want to learn Java and arithmetic, and so that's what the Java and other languages have to do. Basic Calculation 0-0

Source: Internet
Author: User
Tags arithmetic naming convention

Why learn Java

1. Arrangements
2. Life

Basic data types and arrays
1. The name of the identifier should have a rule, so it's called a naming convention. 1. A standard English name 2. Package Lowercase 3. class first uppercase 4. Constant all uppercase 5. Variable first letter lowercase, followed by the first letter of the word

2.unicode Character Set

65,536 characters The first 128 ASCII code corresponds to the Java language using the Unicode standard character set so this is the same as the number of char? -?

3. Basic data types

Four categories of eight

Logical Type: Boolean

Integer type: Byte, short, int, long

Character type: Char

Floating-point type: float, double (eight-bit, 16-bit valid digits are reserved respectively)

Focus on the number of bytes and the range of values a byte eight bit byte1,short2,int4,long8,char2,float4,double8, so the value range is-(2 8*bit) The 8*bit of the square-1 The reason for this is because 0 of the positive side of the char type does not have a negative value, you can see the corresponding value of char by the int type conversion, which is especially logical type, summarized down is the case.

Type conversions

Level low assignment to level high automatic upgrade level high turn level low cast over range may result in loss of precision

Hierarchy: Byte, short, char, int, long, float, double

At this point I would like to ask: .... The answer should be to conserve resources.

4. Input and output

Input data Let me think about how C and Python input data in the console? -? Learned ... But I forgot.

C language with scanf and then inside be sure to remember A & seems to be

Pyhton directly with an input super cool

Then Java uses scanner This class is JDK1.5 to start using, do not know what to read the input before jdk1.5? No matter first, learn how to use 0-0scanner

For example, to read an int type of data

int i=0;

Scanner a=new Scanner (system.in);

I=a.nextint ();

It turned out to be so, the same brothers and Nextboolean, nextdouble ... and other basic data types;

Now think about how to read a row. 0-0 string the kind of P/s seems to be used nextline and then there seems to be some pits, do not remember, later to fill.

Output

The output of the words System.out.println (), after the output line, of course, there is no way to wrap and format output (JDK1.5), but this is not the point, anyway I can output.

PS: Every time you read to the JDK there is an impulse to see the document, I heard that the future company may use jdk1.7,jdk1.8 and then the school jdk1.2 plus a little must be the other version. But the JDK you're using is almost jdk11.

Array 0-0 hehe

What kind of language is this array in, and what is the definition of the array? It seems that a set of variables of the same type, in fact, is a set of the same type of data, if there is a problem, the data can be many groups. The function of the array is, of course, a lot easier to manipulate, and then there are more prescriptive data. Wait for me Baidu a bit hey

Declaring an array in Java seems like there are some places to be aware of

int a[]; int b[][]; This is a good understanding of the version, and then there are some very nasty statement, do not know whether to test ah what, anyway, there is always someone very bored, you can use something to test some of the things you do not normally think, so I still look, deal with him.

I heard that when bored to learn, because of learning, you will find there are more interesting things to interrupt you. 0-0 did not say study 0-0;

int [] a B; what does this mean? Equivalent to an int a[],int b[] means declaring two variables

int [] a,b[]; What is this? 0-0 equivalent to int a[], int b[][]; This is a little bit more.

Of course Java differs from C and C + +, and Java does not allow the number of elements in the array to be specified within the square brackets in the declaration array. Just like int a[2] This is not possible, as for the reason, I do not know temporarily 0-0 but I will Baidu

OK, I probably understand, that is, we have to do this, because it is more safe, better. However, for what variables, can the reference assignment all together? Don't want to pull the wrong.

Oh, it's best to paint one-dimensional arrays and two-dimensional arrays of what, after all, the array is a reference variable, reference variables generally like to test this what, and then AH is the stack, but now seems to be divided into heaps and non-heap.

Do not know that I understand the right, if there is a big guy to see, and then can point out the good, haha, or I will wait for the next time I re-experience the time to see.

Java first time experience with doubt "1" basic data types and arrays and why I want to learn Java and arithmetic, and so that's what the Java and other languages have to do. Basic Calculation 0-0

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.