Man how can you say simple and easy then use loops
@4ugaming6932 ай бұрын
type mismatch bro
@fathurrahmannursaputra42192 ай бұрын
can you create for google gemini ?
@TheMrTuanVu2 ай бұрын
thank you a lot for this video!
@JSR24282 ай бұрын
Why you use that + sign with result?
@mintype7 күн бұрын
the plus makes it so the thing after gets ADDED to the string. so the string starts off with nothing in it and each time it goes through the for loop, one letter from the str string is added to result. (it goes backwards so its reversed.)
@blackscience82082 ай бұрын
The explanation is very good and easy to understand, i am a teenager and i understood it clearly☺☺
@hosteldays35093 ай бұрын
Yes I use my api key but it why the link cgatgpt link is not working
@RealTrueguy643 ай бұрын
tysm!!
@meoconhoccode3 ай бұрын
free account can't use api :(
@ajeetkumarsingh13023 ай бұрын
great video man probably shortest programming video i have watched on youtube. i am new to coding how do i excel in this
@mintype7 күн бұрын
just keep coding :) if u dont know what to code go learn something new and maybe some cool ideas will pop into ur head!
@xebex54514 ай бұрын
thanks man!!
@mintype7 күн бұрын
yw
@maksim122334 ай бұрын
why you use swing? you need to use javaFX
@mintype4 ай бұрын
Some people want to learn swing. I can teach both so it’s fine. If I make a JavaFX video I’ll put it in the title.
@thedadbrains4 ай бұрын
you're amazing!
@mintype4 ай бұрын
Wow, thank you!
@giveaway56305 ай бұрын
Requires GPT-4, because when reading an error message after asking, getting insufficient credits
@mintype4 ай бұрын
It means your openAI account doesn’t have any funds/money left
@oshadhaedirisinghe14555 ай бұрын
Thank you
@mintype7 күн бұрын
yw
@baseplate_4625 ай бұрын
im not exactly sure i understand why we do .length - 1; what is the -1 for?
@almira40084 ай бұрын
-1 means the index of last character, because index starts from zero, so when you want to get last characters' index you should add this -1
@HorridOnlineTroll3 ай бұрын
array {1, 2, 3, 4, 5} There's 5 elements inside, it has a length of 5. However, if we want to know the index of each element inside the array the value '1' is at position '0' which means element '5' is at position '4', so to get the value '5' we need to write array[4]. given N is the length of the array, n-1 determins the position of those elements. If simple wrote i = str.length; you would get an out of bounds exception element because the element '5' is at position '4', not position '5'. Following the formular n-1, we say str.-length-1 to ensure we always end up at the last element contained within the array.
@ravalimanchala81702 ай бұрын
Thank you for your valuable information
@frailedtea2 ай бұрын
@@HorridOnlineTroll You're amazing!
@douglassousa91885 ай бұрын
Não funcionou
@user-tx6qd8fs1h5 ай бұрын
I think API keys are expired now, so we must pay to run the code? Plz. reply me as fast as you can, i must finish my project in next two weeks
@mintype5 ай бұрын
Yeah you have to pay but its really cheap
@yashbhatt94426 ай бұрын
Will this run in bluej
@mintype6 ай бұрын
If it's java, it's going to work. If it doesn't you most likely forgot to import something.
@hyperkarlotheweeb29697 ай бұрын
Thank youuuuu
@mintype6 ай бұрын
Glad to help!
@hudashaikh51699 ай бұрын
i got server 429 error for first time why is it happening
@mintype9 ай бұрын
Check your api key is working and valid. Make sure it is not expired if it is a free trial.
@ajwadshine46389 ай бұрын
Thanks preciate it.
@mintype9 ай бұрын
No problem!
@chrism282810 ай бұрын
I keep getting an exception out of bounds error and I’m not sure why.
@mintype9 ай бұрын
send ur code here
@mathsbigsecrets610010 ай бұрын
I get an "Server returned HTTP response code: 429" Error. I believer the BufferedReader in is what's causing the issue. Any ideas on what might be going wrong?
@mintype10 ай бұрын
Check your api key is valid not expired and works. Also check how much free trial money you have left if you are in the free trial. (Other people have had the same issue before)
@irisrin10 ай бұрын
my results came out diffrent
@mintype10 ай бұрын
Can you provide some info? Like give me your code so I can see whats wrong. Also maybe tell me your version of Java? New Java versions come out all the time and can break old code. discord help server: discord.gg/hhGu6mV5wm <-----
@kevswags10 ай бұрын
I think i found an easier way: String s = "123456789"; StringBuilder x = new StringBuilder(s); x.reverse(); String output = x.toString(); System.out.println(output);
@mintype10 ай бұрын
Your way works and is more simple than my way, however this video is supposed to teach those who don’t know how to reverse a sting WITHOUT StringBuilder. (For example in a AP CSA class they would ask you to do this without StringBuilder)
@HorridOnlineTroll3 ай бұрын
interviews tend to not allow things like StringBuilder, while yes it is more efficient, they want to see if you know the fundamental logic
@proyoloks138610 ай бұрын
ah yes, short... thank you :)
@mintype10 ай бұрын
You're welcome! There’s no reason learning something like this should take super long.
@deev358210 ай бұрын
Nice tq i got a great java tutorial channel
@mintype10 ай бұрын
Happy to help
@-GordonFreeman10 ай бұрын
I asked a chatbot to kill itself so i wanted this to make the suicide seem real
@mintype10 ай бұрын
what
@-GordonFreeman10 ай бұрын
@@mintype Thank you, it worked kzfaq.infoFB6--ys9yGM?feature=shared
@ELLIOT-uq8nc10 ай бұрын
YOU SHOULD MAKE MORE VIDEOS BRO
@mintype10 ай бұрын
On what
@ELLIOT-uq8nc10 ай бұрын
on this topic ofc@@mintype
@nahidasultana684211 ай бұрын
Hi, I am having an error. what mistake i have made? package Practice; public class HelloReverse { public static void main(String[] args) { String input ="Hello world!"; String output=" "; for(int i=input.length()-1;i>=0;i--); output+=input.charAt(i); System.out.println(output);
@mintype10 ай бұрын
You have a ; (semicolon) at the end of your for loop!!!! updated code: String input ="Hello world!"; String output=" "; for(int i=input.length()-1;i>=0;i--) output+=input.charAt(i); System.out.println(output);
@nahidasultana684210 ай бұрын
@@mintype Thank you so much!
@ravalimanchala81702 ай бұрын
Thank you
@ravalimanchala81702 ай бұрын
Thank you
@ravalimanchala81702 ай бұрын
Thank you
@debalinaghosh640411 ай бұрын
when I ask for a java program it is not giving the complete output. Could you help me in this?
@mintype11 ай бұрын
Prompt the API with "continue" after if it is incomplete.
@mintype11 ай бұрын
join the discord! -> discord.gg/hhGu6mV5wm
@mintype11 ай бұрын
join the discord! -> discord.gg/hhGu6mV5wm
@mintype11 ай бұрын
join the discord! -> discord.gg/hhGu6mV5wm
@mintype11 ай бұрын
join the discord! -> discord.gg/hhGu6mV5wm
@mintype11 ай бұрын
join the discord! -> discord.gg/hhGu6mV5wm
@shashivadhangunti341111 ай бұрын
where is the code
@mintype11 ай бұрын
Its the pinned comment.
@bankarsandipk Жыл бұрын
Nice short explanation 😊
@mintype Жыл бұрын
Glad it was helpful!
@joseangelnavarro4116 Жыл бұрын
I can't get the code to work. Error 429. I have created another user with another key
@mintype Жыл бұрын
Error 429 may happen to you if you send too many requests in a short period of time.
@joseangelnavarro4116 Жыл бұрын
@@mintype with a new user and new key if i do the first request the code is it. Is possible any change with free counter politic?
@ece03abhisheksrivastava646 ай бұрын
@@mintype Bro even showing 429 for first time call 🤔
@ReeachyZ_4 ай бұрын
@@mintypein first request this happens
@my__type43 ай бұрын
Does anyone solve this problem? I'm having the same issue. I'm using Eclipse IDE
@mintype Жыл бұрын
join my discord :) --> discord.gg/hhGu6mV5wm
@user-pu5bm7cj9w Жыл бұрын
Hey, how could I get the Java codes? You mentioned that check description, but I failed to find it...
@mintype Жыл бұрын
Heres the code (updated): import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static void main(String[] args) { System.out.println(chatGPT("hello, how are you?")); // Prints out a response to the question. } public static String chatGPT(String message) { String url = "api.openai.com/v1/chat/completions"; String apiKey = "KEY GOES HERE!!!!!!!!!!!"; // API key goes here String model = "gpt-3.5-turbo"; // current model of chatgpt api try { // Create the HTTP POST request URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Authorization", "Bearer " + apiKey); con.setRequestProperty("Content-Type", "application/json"); // Build the request body String body = "{\"model\": \"" + model + "\", \"messages\": [{\"role\": \"user\", \"content\": \"" + message + "\"}]}"; con.setDoOutput(true); OutputStreamWriter writer = new OutputStreamWriter(con.getOutputStream()); writer.write(body); writer.flush(); writer.close(); // Get the response BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); // returns the extracted contents of the response. return extractContentFromResponse(response.toString()); } catch (IOException e) { throw new RuntimeException(e); } } // This method extracts the response expected from chatgpt and returns it. public static String extractContentFromResponse(String response) { int startMarker = response.indexOf("content")+11; // Marker for where the content starts. int endMarker = response.indexOf("\"", startMarker); // Marker for where the content ends. return response.substring(startMarker, endMarker); // Returns the substring containing only the response. } }
@supercodingandmath2826 Жыл бұрын
@@mintype hello
@PokeMichele Жыл бұрын
I don't know why it always refuses the connection when i try to execute it
@mintype Жыл бұрын
Check if your API free trial has expired yet. Many people get the same issue and don't realize their trial has expired.
@flashu09 Жыл бұрын
how to make a bind like if i pres r start clicking and agin a press r stops clicking ? pls help
@mintype Жыл бұрын
One way to do this is to create a GUI with Java Swing or JavaFX. I have a video on swing. Then you can use keyListener to listen for the R key and turn it on or off. However, please take note that the GUI has to be open when you press R on your keyboard. Java doesn't have any way of doing this without the GUI focused. (There are GitHub repositories which might help, but I'm not certain they work!)