How can a Java programmer with a monthly salary of tens of thousands not understand logical operators and basic data types?

2021/08/2923:37:05 technology 2648

Hello, everyone. The weekend is over, I don’t know how you’re doing these two days? Did you study hard to enter the IT industry? If you are not in a hurry, you can follow my article and learn slowly. No matter what you do, there is no shortcut at all. It will be easier to succeed with the accumulation of time.

Speaking of the homework we assigned last time, everyone should be able to read the code. Except for one place, that is this symbol: &&

How can a Java programmer with a monthly salary of tens of thousands not understand logical operators and basic data types? - DayDayNews

&&

In life, for example, if you plan to go out to play with a friend, when he asks you and how to answer?

A: Weekend;

B: Saturday or Sunday;

C: I have something on the weekend, other time!

If we translate these three situations in terms of Saturday and Sunday, they are: and, or, and not.

means Saturday and Sunday, Saturday or Sunday, non-Saturday and Sunday!

In Java, we are used to calling "and" as "and", that is, and, or, and not.

But Java was invented by foreigners, and foreigners will definitely not say yes or no, so how do we use these three conditions in the programming language ?

is very simple, and the corresponding is &&, or the corresponding is ||, the non-corresponding is !.

How can a Java programmer with a monthly salary of tens of thousands not understand logical operators and basic data types? - DayDayNews

and NOR

As long as you hold down the Shift key and press these keys again, you can type it out! Remember to cut into English mode!

For example, define a variable x:

if x> 0 and x <2,> 0 && x <2;>

if x> 0 or x <2,that> 0 || x <2;>

If x> 0 is required, one is to write positively, x> 0; the other is to write backwards! (x ≤ 0), which means that x is less than or equal to 0 Inverted, it becomes x> 0.

Why add parentheses? If you write it directly as !x ≤ 0, it becomes the inversion of x first, and then use it to compare with 0! The three symbols

are called logical operator in Java! There are only two results after being operated by logical operators, true or false!

For example, a number is greater than zero && a number is less than zero, is it possible? It is never possible, so after this operation is over, it will return a false.

true and false are called boolean in Java, corresponding to true and false .

How can a Java programmer with a monthly salary of tens of thousands not understand logical operators and basic data types? - DayDayNews

true

How can a Java programmer with a monthly salary of tens of thousands not understand logical operators and basic data types? - DayDayNews

false

Remember we mentioned the concept of data types in the last article? How many data types can we think of ourselves?

For example, age, this is a integer right, no one is 17.9 years old this year!

we just mentioned,True or false, this is called Boolean type .

I got 59.5 points in the test today. This is called a decimal in mathematics. In the computer we call it floating point number !

is there any more? If not, then I ask you, abc in English and hello in Chinese, how do you store it in the computer?

Yes, there is another type called character type !

So far, we can store everything in the world in the computer! But not enough, not enough?

is not detailed enough!

You must know that the memory of a computer is limited. In ancient times, in order to make the computer do as much as possible, it can be described as racking their brains and trying to reduce the overhead of memory.

Although with the development of our science and technology, the memory has become very large and also cheap. For example, now any U disk is tens or hundreds of gigabytes, and it only costs a dozen or twenty yuan. Back then, I bought a 1G USB flash drive, but it cost nearly 100 yuan!

However, despite this, there is still a barrier to memory! At present, there is a limit to anything that humans can encounter. For example, the earth is very large, but it also has a limit. It is just that big!

is the same as a computer, you just want to make a 1 + 1, and it will take up all of its memory. Is this reasonable?

So for integers, we have made a certain division:

byte : can only store numbers between -128 and 127

short : can only store numbers between -32768 and 32767 The number between

int : Only numbers between -2147483648 and 2147483647 can be stored,Probably from a negative 2.1 billion to a positive 2.1 billion

long : It is quite large, about 922 Jing. What is the concept of Jing? Jing is ten thousand trillion, trillion is one trillion, you can basically understand that you can store any number!

has two divisions for floating-point numbers. The specific difference is only the difference in precision. For example, the number of the double type can be longer than the number of the float type and has more decimal points:

float : single precision

double : double-precision

Generally speaking, for modern computers, their memory is not so tight, so we only use int, long, and double. And this type of floating point number is quite impractical. has precision problems , which should be eliminated. We will talk about another thing later, called Decimal .

Everyone in the daily coding process should be prohibit the use of float or double .

The remaining character types and boolean types are not subdivided, they are char and boolean respectively.The character value must be English single quotation marks to include , and the boolean value can only be true or false !

Below we directly declare in the code

How can a Java programmer with a monthly salary of tens of thousands not understand logical operators and basic data types? - DayDayNews

basic data types

These 8 types are called the eight basic data types in Java. Careful friends will notice that I added an f after float . What does this mean?

This is the type of designated number. Didn't we say that there are 4 types of integers and two types of decimals. Then we directly declare a 1.0, how does the computer know whether it is a single-precision float or a double-precision double?

The computer is really stupid, and many things require us to name it. In Java, if you declare an integer, it is of type int by default, and if it is a decimal, it is of type double by default!

If you want to specify its type yourself, you must explicitly follow the type mark after the number. Java supports the following three marks:

double f = 1.0D; float e = 1.0F; long d = 4L;

is also D, F, L , of course, you can also use lowercase d, f, l. But lowercase L is difficult to distinguish from 1, so if you really want to use it, uppercase is recommended!

As for the char type, we only support one character in quotation marks, that is, if you write char g ='abcd',This will directly report an error! It should be noted that a Chinese is also a character, such as char g ='you', there is no problem.

So we just want to save abcd? Java provides you with another type called String .

String type value must be enclosed in English double quotation marks, such as String g = "abcd".

Concluding remarks

Recently, overtime has been relatively frequent, and the article is almost 4 o’clock after the completion of the article. I hope you can support me. If you have any questions, please feel free to raise them.

In terms of programmers, although the salary is higher than other industries, it is actually quite difficult to calculate it. However, a few days ago, the Ministry of Human Resources and Social Affairs of and the Supreme Court jointly issued ten typical cases of overtime labor and personnel disputes, clarifying that the working systems of 996 and 007 are illegal.

As soon as this event is fermented, every company will probably converge more or less. At least for overtime work, there are shifts and pay, and you have to choose one of them. This is a good news for most job seekers.

In fact, this can be considered luck. Some people may enter a company that does not work overtime at all and clocks in on time every day. Some people may not encounter this kind of benefits no matter how many times they jump, such as me!

.

technology Category Latest News