Table of Contents
​Foreword
Plug-in installation
Try it
Conclusion
Home Technology peripherals AI Oh my god, is ChatGPT really going to work for us?

Oh my god, is ChatGPT really going to work for us?

Apr 13, 2023 am 08:19 AM
business chatgpt code

​Foreword

ChatGPT​ is really very popular recently, and AI services related to ChatGPT are also being researched in full swing. Today we take a look at the application of ChatGPT in coding. Recently we found an IntelliJ IDEA plug-in called "AI Coding Assistant", which integrates ChatGPT technology. Let's see how smart it is and whether it will really work in the future. It is possible that it will replace the work of our programmers.

Plug-in installation

In order to start using the plug-in, you must have an OpenAI token. If you don't know where to find it, you can get it here https://platform.openai.com/account/api-keys on how to register. Baidu and Google have a lot of tutorials.

In addition, download and install the "AI Coding Assistant" plug-in for IntelliJ IDEA:

Oh my god, is ChatGPT really going to work for us?

Figure 1 - "AI Coding Assistant" plug-in in IntelliJ IDEA settings

Try it

  1. Generate the code to print hello world

The first task is a simple one, which is to let it automatically generate and print hello world code.

Oh my god, is ChatGPT really going to work for us?

  1. Generate a pojo

Now you generate a Person class for me.

Oh my god, is ChatGPT really going to work for us?

  1. Now create a function for me to return the generated list of people

Oh my god, is ChatGPT really going to work for us?

  1. After having the person data , we can implement some simple algorithms, such as finding the oldest person in the list, the minimum/maximum/average age of the people in the list

Oh my god, is ChatGPT really going to work for us?

  1. The interesting part of this is that we can ask to update the existing code. Since I know a better way of writing the same algorithm using the Java Stream API, let's try to make it refactor

Oh my god, is ChatGPT really going to work for us?

  1. We can create a function and ask it to generate code based on the meaning of the function name.​

Oh my god, is ChatGPT really going to work for us?

  1. Then you I also added the javadoc

Oh my god, is ChatGPT really going to work for us?

  1. Can you also add comments to my code and explain what this code does? ?​

Oh my god, is ChatGPT really going to work for us?

  1. Finally, let’s take a look at what the final code generated by this AI plug-in looks like?​
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.IntSummaryStatistics;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
final List<Person> people = generatePeople();
// find oldest person in the list
Person oldestPerson = people.stream()
.max(Comparator.comparing(Person::getAge))
.orElseThrow(NoSuchElementException::new);
System.out.println("Oldest person is: " + oldestPerson.getName());
// find max,min,avg age of the people
IntSummaryStatistics stats = people.stream()
.mapToInt(Person::getAge)
.summaryStatistics();
System.out.println("Max Age: " + stats.getMax());
System.out.println("Min Age: " + stats.getMin());
System.out.println("Avg Age: " + stats.getAverage());
}

public static List<Person> generatePeople() {
return Arrays.asList(
new Person("John", 25),
new Person("Jane", 30),
new Person("Jack", 20),
new Person("Jill", 35)
);
}

/**
* Capitalizes the first letter of a given string and lowercases the rest.
*
* @param s The string to capitalize
* @return The capitalized string
*/
public static String capitalize(String s) {
/*
This code checks if the length of the string "s" is 0. If it is, it returns the string.
If not, it returns the first character of the string in uppercase and the rest of the characters in lowercase.
*/
if (s.length() == 0)
return s;
return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
}
}

// class Person with name and age
class Person {
private String name;
private int age;

public Person(String name, int age) {
this.name = name;
this.age = age;
}

public String getName() {
return name;
}

public int getAge() {
return age;
}
}
Copy after login

Conclusion

Using AI such as ChatGPT can generate some codes, as shown in the example above, but it is still impossible to face some complex businesses. We can use such tools to help us improve efficiency at work, but don’t worry that they will replace us.

The above is the detailed content of Oh my god, is ChatGPT really going to work for us?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

ChatGPT now allows free users to generate images by using DALL-E 3 with a daily limit ChatGPT now allows free users to generate images by using DALL-E 3 with a daily limit Aug 09, 2024 pm 09:37 PM

DALL-E 3 was officially introduced in September of 2023 as a vastly improved model than its predecessor. It is considered one of the best AI image generators to date, capable of creating images with intricate detail. However, at launch, it was exclus

How to solve win7 driver code 28 How to solve win7 driver code 28 Dec 30, 2023 pm 11:55 PM

Some users encountered errors when installing the device, prompting error code 28. In fact, this is mainly due to the driver. We only need to solve the problem of win7 driver code 28. Let’s take a look at what should be done. Do it. What to do with win7 driver code 28: First, we need to click on the start menu in the lower left corner of the screen. Then, find and click the "Control Panel" option in the pop-up menu. This option is usually located at or near the bottom of the menu. After clicking, the system will automatically open the control panel interface. In the control panel, we can perform various system settings and management operations. This is the first step in the nostalgia cleaning level, I hope it helps. Then we need to proceed and enter the system and

What to do if the blue screen code 0x0000001 occurs What to do if the blue screen code 0x0000001 occurs Feb 23, 2024 am 08:09 AM

What to do with blue screen code 0x0000001? The blue screen error is a warning mechanism when there is a problem with the computer system or hardware. Code 0x0000001 usually indicates a hardware or driver failure. When users suddenly encounter a blue screen error while using their computer, they may feel panicked and at a loss. Fortunately, most blue screen errors can be troubleshooted and dealt with with a few simple steps. This article will introduce readers to some methods to solve the blue screen error code 0x0000001. First, when encountering a blue screen error, we can try to restart

The computer frequently blue screens and the code is different every time The computer frequently blue screens and the code is different every time Jan 06, 2024 pm 10:53 PM

The win10 system is a very excellent high-intelligence system. Its powerful intelligence can bring the best user experience to users. Under normal circumstances, users’ win10 system computers will not have any problems! However, it is inevitable that various faults will occur in excellent computers. Recently, friends have been reporting that their win10 systems have encountered frequent blue screens! Today, the editor will bring you solutions to different codes that cause frequent blue screens in Windows 10 computers. Let’s take a look. Solutions to frequent computer blue screens with different codes each time: causes of various fault codes and solution suggestions 1. Cause of 0×000000116 fault: It should be that the graphics card driver is incompatible. Solution: It is recommended to replace the original manufacturer's driver. 2,

Resolve code 0xc000007b error Resolve code 0xc000007b error Feb 18, 2024 pm 07:34 PM

Termination Code 0xc000007b While using your computer, you sometimes encounter various problems and error codes. Among them, the termination code is the most disturbing, especially the termination code 0xc000007b. This code indicates that an application cannot start properly, causing inconvenience to the user. First, let’s understand the meaning of termination code 0xc000007b. This code is a Windows operating system error code that usually occurs when a 32-bit application tries to run on a 64-bit operating system. It means it should

GE universal remote codes program on any device GE universal remote codes program on any device Mar 02, 2024 pm 01:58 PM

If you need to program any device remotely, this article will help you. We will share the top GE universal remote codes for programming any device. What is a GE remote control? GEUniversalRemote is a remote control that can be used to control multiple devices such as smart TVs, LG, Vizio, Sony, Blu-ray, DVD, DVR, Roku, AppleTV, streaming media players and more. GEUniversal remote controls come in various models with different features and functions. GEUniversalRemote can control up to four devices. Top Universal Remote Codes to Program on Any Device GE remotes come with a set of codes that allow them to work with different devices. you may

How to install chatgpt on mobile phone How to install chatgpt on mobile phone Mar 05, 2024 pm 02:31 PM

Installation steps: 1. Download the ChatGTP software from the ChatGTP official website or mobile store; 2. After opening it, in the settings interface, select the language as Chinese; 3. In the game interface, select human-machine game and set the Chinese spectrum; 4 . After starting, enter commands in the chat window to interact with the software.

What does the blue screen code 0x000000d1 represent? What does the blue screen code 0x000000d1 represent? Feb 18, 2024 pm 01:35 PM

What does the 0x000000d1 blue screen code mean? In recent years, with the popularization of computers and the rapid development of the Internet, the stability and security issues of the operating system have become increasingly prominent. A common problem is blue screen errors, code 0x000000d1 is one of them. A blue screen error, or "Blue Screen of Death," is a condition that occurs when a computer experiences a severe system failure. When the system cannot recover from the error, the Windows operating system displays a blue screen with the error code on the screen. These error codes

See all articles