I used ChatGPT to correct bugs and I was shocked!

Hello everyone, I am the stack manager.

ChatGTP is recognized as the strongest AI model in the world and can do too many things. .

For programmers, ChatGPT can automatically generate code, code completion, code analysis, programming language conversion, write SQL, and write programsWait a minute, let me give you a few simple demonstrations.

1. Code generation

ChatGPT can automatically generate code based on instructions and requirements entered by programmers.

For example, we can enter " to create a class named xx, which contains two attributes A and B. Attribute A is an integer and attribute B is a string< /span>", then ChatGPT can automatically generate class definition code that meets the requirements:

7c481ee83637e37c0218a26db219fc5a.png

For another example, I asked to write a bubble sort algorithm in Java:

0016c6eed5992a7d435acbc214996c1b.png

These codes can be used directly. I usually ask them to write other functions, functions, web pages, or even small games , it’s all a piece of cake, it’s so scary! !

2. Code analysis

ChatGPT can automatically generate comments based on the code to explain the function and role of the code.

932375a9a9931c02a04be8701d8fa02e.png

Can’t understand the source code of the technical framework?

Just throw it to it for analysis.The comments are written for you, which can greatly improve your ability to read and analyze the source code. If it is open source code, you don't even need to give it the code, it can find and analyze it by itself.

3. Help you fix bugs

Write a piece of problematic code and throw it to ChatGPT:

/**
 * 公众号:Java技术栈
 */
public class Test {

    private static int counter = 0;

    private static final CountDownLatch cdl = new CountDownLatch(100);

    public static void main(String[] args) throws Exception {
        for (int i = 0; i < 1000; i++) {
            new Thread(() -> {
                for (int j = 0; j < 1000; j++) {
                    counter++;
                }
                cdl.countDown();
            }).start();
        }
        cdl.await();
        System.out.println("计数器的值: " + counter);
    }
}

Let’s throw it to ChatGPT for detection:

869f12aa9a2e909f866e7c571753267c.jpeg

It’s so powerful that I was shocked.It found all the problems and gave solutions and improved code. After the modification, there were no problems. ChatGPT is ridiculously powerful. .

I use it every day when creating public accounts and small program Java interview libraries.Many people don’t know Baidu at all, so they can directly display solutions, you can’t be too relaxed, simplicity is an artifact of development efficiency, and I can’t live without it anyway.

What I shared above is just the tip of the iceberg of ChatGPT’s capabilities. I will share more ChatGPT usage tips in the following columns.


The stack manager's "Playing with ChatGPT" column is here!

d023cd72cd39b1cd90931a144e12a552.jpeg

1. This column mainly shares ChatGPT  essential knowledge, usage guides and application practices, and does not share content irrelevant to this column, including Network, registration, recharge, etc.

2. This column is not about cutting leeks. I am also a senior player of ChatGPT. I promise to update at least 50+ articles, and I have updated more than 10 articles. , don’t play fake, take you to play ChatGPT.

3. This column is currently priced at a special price of 10 yuan for internal testing (permanent buyout). Any point you learn is worth the price. There will be a step-by-step price increase in the future, and the final price will be 199 yuan. Those who have subscribed will not be affected.

4. After subscribing, add the author's WeChat account: 160285345, send a screenshot of the subscription, and receive a free copy of "The Strongest Guide to ChatGPT Prompt Words.pdf".


I have promoted it in the circle of friends in the past two days, and 200+ people have subscribed.

Yes, the current internal price is 10 yuan, permanent buyout learning, 10 yuan, 10 bucks, 10 bucks! ! If you don’t make money in the early stage, just make friends and boost sales~

Scan the code when you see it and get on the bus.Subscribing early is an advantage. You can also subscribe later, but it will be more expensive. It is definitely This price is no longer available. The price will increase by RMB 10 for every 500 people!

682b7dc5bfc4cb4b2872288d325dcd3e.jpeg

Regardless of whether you can use it or not, it's just a breakfast fee, so you can subscribe to it as a backup, or just to increase your knowledge.

582f585de5bc7e6f3edb3d5c05edb1f4.pngClickRead the original textLink to subscribe quickly

Guess you like

Origin blog.csdn.net/youanyyou/article/details/134635872
I
"I"