The problems encountered by the beginners of Java learning

Preface

In the past week, I learned the knowledge of java introductory. Of course, as an adorable new person, I must have encountered various problems in the process of learning. I think it will be recorded one by one, and it will be the same as the correction book in my learning journey.

Case problem

Java is a computer-oriented language, but more often it needs to be read by humans, so people have stipulated various regulations, of which the issue of capitalization is very important.

example

In the program Hello Java program, I wrote it with Notepad. Insert picture description here
Believe that I can see the problem at a glance, and the S of String must be capitalized. At that time, I was looking for this problem for a long time.

Understanding of the basic types of data

After getting acquainted with the various program windows of Java, it is to learn the basic data types of Java. Because this article mainly talks about the problems encountered, the knowledge points are not introduced.
The biggest problem I encountered in this area is the use of floating point.

example

int m = 3;
float n = 3;
System.out.println("三除以二的值为:" +(m/2));
System.out.println("三除以二的值为:" +(n/2));

The results of the operation let me calculate that both are 1.5, but the answer given by the computer is one is 1 and the other is 1.5
. I learned this at the time. I can't help but lament that the computer's brain is still not as flexible as the human brain!

Understanding of = and ==

example

public class{ public static void main(String[] args) { int a = 23432; //Define a five-digit integer int b = a/10000; //Take out the value of ten thousand int c = (ab 10000)/ 1000; //Remove the value of thousands int d = (ab 10000-c 1000)/100; //Remove the value of hundreds int e = (ab 10000-c 1000-d 100)/10; //Remove the tens The value of int f = ab 10000-c 1000-d 100-e 10; //Remove the value of the ones place System.out.print("Whether it is a palindrome:"); System.out.print(b == f && c == e); //Judging the Boolean value } } This question is very simple, it is to judge whether it is a palindrome number, but I still encounter some problems in understanding when judging the values ​​are equal in the last line of the code . == Two equal signs judges Boolean values, and = an equal sign is assignment, which is still far from my daily mathematics.











Guess you like

Origin blog.csdn.net/weixin_46687295/article/details/105818787