Self study python for one year, and finally transform into a java Engineer!

Posted by popsiclesph on Sun, 21 Jun 2020 10:24:05 +0200

The language is the same, no matter c, python or java, the syntax feels similar, but Python is really hard to find a job. Several recruitment platforms have looked around, and there are only a few, so they sprouted the extension java route to make up for the advantages of job search. In the future, you may spend more time learning java. Python is better to study crawlers every week to add some fun.

There's no end to learning, from Python to Java, from the compiler-----

Maybe I had a good foundation before. I think it's very smooth to watch java. I didn't buy a book. I just found some videos on the Internet, He took me to learn some java key words and basic system conveniently. Almost a week later, I finished all the knowledge of the introduction, and then I started to write some code by myself, do something, and go to Baidu if I can't understand the grammar. Anyway, don't stop my learning!

python is simple. It doesn't need many definitions. It can be used just by using it,

Java is complex. It needs variable declaration and initialization value. In some cases, it does a lot, but the execution speed is very fast

How to switch between two languages? It's very simple. You need to think a little more about using python and java. At least it's OK for me to switch like this, and there won't be a lot of contradictions.

Start with the Java compiler:

I didn't think of anything else. At the beginning, I learned to ask the big guys what to use. When someone mentioned IDEA, I just went to IEDA directly. Anyway, it's the same as pycharm interface, shortcut keys and so on. It's easy to use. I don't like other compilers very much. They don't have code completion, which is not suitable for novices, nor for my pursuit of percussion speed party, So IDEA is a good choice.

Planning the route or something;

How many people still remember their childhood dreams? For example, when they were little, they said, "I want to be a scientist, an astronaut, a star, etc.", that's the innocence of children. Now, brothers, whether dreams are important or money is important, we should always bear the responsibility of making money. Don't think about the route first, Take a moment to start with the basic grammar and look at the official documents. The route is what industry we want to make more money, make more money, and make more money. After getting started, this is your route. For example, if I want to develop Android later, I may go back to these frameworks to learn. If I think what I said is bullshit, you can't learn by yourself, Then you can spend some money to go to the training class, where there is a whole set of route planning, after all, it's the taste of money, and others will pave the way for you and encourage you.

The first JAVA chess game written:

In fact, this game is very simple. If I use python, which is 70-80 lines, it's easy to complete. But because I learned java, I need to be familiar with the java syntax. He uses more than 120 lines of me. Compared with Python, it's not simple, but it doesn't matter.

Put the code below, and take what you need. It's a little exercise.

import java.util.Scanner;
import java.util.concurrent.ScheduledExecutorService;

public class ChessGame {
    public static void Input(int x, int y, String flag, String[][] chess) {
        // Create a chessboard based on the position continuously entered by player 1 and player 2
        chess[x - 1][y - 1] = flag;
        Look(chess);
        Judge(chess);
    }

    public static void Judge(String[][] chess) {
        // Judge once for each input until the end of the game
        for (int i = 0; i < chess.length; i++) {
            if ((chess[i][0] == chess[i][1]) && (chess[i][1] == chess[i][2])) {
                // Judgment line
                if (chess[i][0] == "x") {
                    System.out.print("Player one wins");
                    // close program
                    System.exit(0);
                } else if (chess[i][0] == "o") {
                    System.out.print("Player 2 wins");
                    // close program
                    System.exit(0);
                }
            } else if ((chess[0][i] == chess[1][i]) && (chess[1][i] == chess[2][i])) {
                // Judgement column
                if (chess[0][i] == "x") {
                    System.out.print("Player one wins");
                    // close program
                    System.exit(0);
                } else if (chess[0][i] == "o") {
                    System.out.print("Player 2 wins");
                    // close program
                    System.exit(0);
                }
            }
        }
        if ((chess[0][0] == chess[1][1]) && (chess[1][1] == chess[2][2]) &&
                chess[1][1] != "\t") {
            // Judge the positive diagonal
            if (chess[0][0] == "x") {
                System.out.print("Player one wins");
                // close program
                System.exit(0);
            } else if (chess[0][0] == "o") {
                System.out.print("Player 2 wins");
                // close program
                System.exit(0);
            }
        }
        if ((chess[0][2] == chess[1][1]) && (chess[1][1] == chess[2][0]) &&
                chess[1][1] != "\t") {
            // Judge diagonal
            if (chess[0][2] == "x") {
                System.out.print("Player one wins");
                // close program
                System.exit(0);
            } else if (chess[0][2] == "o") {
                System.out.print("Player 2 wins");
                // close program
                System.exit(0);
            }
        }
    }

    public static void Look(String[][] chess) {
        // View chessboard
        int count = 0;
        System.out.println("------------checkerboard---------------");
        for (int i = 0; i < chess.length; i++) {
            for (int j = 0; j < chess[i].length; j++) {
                count += 1;
                System.out.print(chess[i][j] + "\t");
                if (count % 3 == 0) {
                    System.out.println();
                }
            }
        }
        System.out.println("------------------------------");
    }

    public static void main(String[] args) {
        // Set up a 3 x 3 ox board game
        System.out.println("This is a 3 x3 Simple chess game, players' home input each other o perhaps x,\n" +
                "Once there are three combos, the player wins!");
        Scanner in = new Scanner(System.in);
        int size = 3;
        String[][] chess = new String[size][size];
        //  Initialize chessboard
        for (int i = 0; i < chess.length; i++) {
            for (int j = 0; j < chess[i].length; j++) {
                chess[i][j] = "\t";
            }
        }
        int x;
        int y;
        for (int i = 0; i < 4; i++) {
            System.out.print("Player 1 input x Location of(3x3):");
            x = in.nextInt();
            y = in.nextInt();
            if (x <= 3 && y <= 3) {
                Input(x, y, "x", chess);
            } else {
                System.out.println("The input position is out of range, please input again:");
                continue;
            }
            System.out.print("Player 2 Input o Location of(3x3):");
            x = in.nextInt();
            y = in.nextInt();
            if (x <= 3 && y <= 3) {
                Input(x, y, "o", chess);
            } else {
                System.out.println("The input position is out of range, please input again:");
                continue;
            }
        }
        System.out.print("it ends in a draw");
    }

}

Postscript:

Life is short. I use python
I want to make money, I use Java

It's sad and true that countless advertisements and platforms can promote python's simplicity and ease of learning, and it's easy to jump to millions of annual salary. More and more people are involved in python's development. I've been involved since last year. After such a long time, I decided to learn more java!

Topics: Java Python Pycharm Android