Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities

For the purpose of job hunting, I found that there were more Java jobs on the market. There are even big data positions that require Java as well as Python. Learn as much as you can while you are young.

1 Operation Habits

  • A semicolon must be added to the end of a line. Python does not issue an error if it is added, but it is not mandatory. Java statements do not issue an error if they are not added{}A little more;
  • Loops such as if cannot be followed by a colon, but must enclose the conditional in parentheses;
  • Print has a few more prefixes that Java uses in front of itSystem.out.. andSystem.out.printlnTo be more common, you can print a newline, andSystem.out.printIs printed on the same line;

  • As shown above, Java must have a main method to execute, and cannot execute without it, whereas Python is more likely to use the following structure if it is object-oriented:
def main() :
   print("Happy National Day!")

if __main__ == "__main__":
    main()
Copy the code

2 Grammar Comprehension

  • The concept of object orientation is stronger. In Python, you’re more likely to run the results line by line, encapsulate what you can as a function, and then go back to defining the class. In Java, the source file name isUser.javaSo it must be in the codeclass UserAll functions of the code are implemented using classes and objects;
  • Class inside call their own member variables, Java usethisPython withself;
  • For variable types, Java most of the time needs to declare the type of a variable, then use the variable, or declare a variable with val, can be automatically converted to the desired type; Python, on the other hand, doesn’t worry too much about these issues and has less constraint on variable types.