I tried to start the timer countdown on a certain input with an if statement. Idk if it didn't like how I was using scanner input, or if the timer stuff doesn't like being in an if statement, but I have yet to make it work how I want it. I'll keep learning, but any help is appreciated. It's not important, just me trying to get ahead of myself, but I like to know how things work. Thanks for the great tutorials!!!
thx bro. I'm wanting code with a "pretend" calendar, so user can jump ahead in time. this video got me started. lately, every java search I make in youtube ends with bro code :)
I took a sneak peak at the explorer section to the left of your screen, I'm quite intrigued by the map project. It would be cool to do something with Google maps API. 🤩
You literally just subed to my channel with 0 Subs and 0 Videos. Do I know you? XD I dont think i ever stumbled across one of your Videos. Why do you know me and where did you find me? XD
@@BroCodez Well, time to change your password. XD I didn't watch these kind of videos. I dont even Programm in java. I just do a little Visual Basic and Mcfunctions. XD
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;
public class Main {
public static void main(String[] args) {
// Timer = A facility for threads to schedule tasks
// for future execution in a background thread
// TimerTask = A task that can be scheduled for one-time
// or repeated execution by a Timer
Timer timer = new Timer();
TimerTask task = new TimerTask() {
int counter = 10;
@Override
public void run() {
if(counter>0) {
System.out.println(counter+" seconds");
counter--;
}
else {
System.out.println("HAPPY NEW YEAR!");
timer.cancel();
}
}
};
Calendar date = Calendar.getInstance();
date.set(Calendar.YEAR,2020);
date.set(Calendar.MONTH,Calendar.DECEMBER);
date.set(Calendar.DAY_OF_MONTH,31);
date.set(Calendar.HOUR_OF_DAY,23);
date.set(Calendar.MINUTE,59);
date.set(Calendar.SECOND,50);
date.set(Calendar.MILLISECOND,0);
//timer.schedule(task, 0);
//timer.schedule(task, date.getTime());
//timer.scheduleAtFixedRate(task, 0, 1000);
timer.scheduleAtFixedRate(task, date.getTime(), 1000);
}
}
Thanks
Practicing...
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;
public class Main{
public static void main(String[]args){
Timer timer = new Timer();
TimerTask task= new TimerTask(){
int counter = 10;
@Override
public void run(){
if(counter>0) {
System.out.println(counter+" seconds");
counter --;
}
else{
System.out.println("Interview with Priscilla");
timer.cancel();
}
}
};
Calendar date = Calendar.getInstance();
date.set(Calendar.YEAR,2023);
date.set(Calendar.MONTH, Calendar.FEBRUARY);
date.set(Calendar.DAY_OF_MONTH,19);
date.set(Calendar.HOUR_OF_DAY,8);
date.set(Calendar.MINUTE, 59);
date.set(Calendar.SECOND,20);
date.set(Calendar.MILLISECOND,0);
//timer.schedule(task,0);
//timer.schedule(task, date.getTime());
//timer.scheduleAtFixedRate(task, 0, 1000);
timer.scheduleAtFixedRate(task, date.getTime(), 1000);
}
}
The language is beautiful, your voice is clear and your teaching is fantastic keep it up bro
You are seriously amazing dude your tutorials alone have taught me Java
Well Im a Fellow Bro 🤜🤛
I tried to start the timer countdown on a certain input with an if statement. Idk if it didn't like how I was using scanner input, or if the timer stuff doesn't like being in an if statement, but I have yet to make it work how I want it. I'll keep learning, but any help is appreciated. It's not important, just me trying to get ahead of myself, but I like to know how things work. Thanks for the great tutorials!!!
Your tutorial is amazing! The best!
tysm! I was looking for a way to run code every 10 milliseconds while something else is running and this helped me a lot.
Loving the java tutos 👍
the king of tutors
thx bro. I'm wanting code with a "pretend" calendar, so user can jump ahead in time. this video got me started. lately, every java search I make in youtube ends with bro code :)
You make the best java tutorials.
my man u are a true legend
Liked
Commented
Subscribed
Really nice video.
I didn't see any documentation on Timer and I found your video
Really helped me understand everything.
Bestt tutor with humour. Thanks alot!
Im brazilian programer and you helped me a lot, thanks bro
the greatest outro ever!
Very few Americans nowdays do Java because it's so hard, so thank you.
Lol
Nice video thank you.
perfect examples thanks a lot
Thank you! This solution was surprisingly hard to find on Google/CZcams
My Chinese teacher created a little game calls plane fight, and in the game he used timer task. To control enemy’s little plane’s speed.
This is fun..like it👍
This helped me a lot :) Thank you
Thanks an unimaginable amount, bro.
Best Java tutorial out there, thanks a lot Bro!
very helpful thank u
thanks . congratulations on 100k subscriber !
Sir I love your videos.
thank you bro very helpfull
Love it
nICE
I took a sneak peak at the explorer section to the left of your screen, I'm quite intrigued by the map project. It would be cool to do something with Google maps API. 🤩
That's a Dungeons & Dragons map generator for a hobby of mine, but a Google Maps program would be a fun project
@@BroCodez I like the fact that you do programming as a hobby, and this would explain why your tutorials are so great. Thank you for them btw.
Super
can you make videos on python projects? if you do, can you add one that has to do with object-oriented programming?
I'll be switching back to Python soon. I wanted to add some more Java videos first due to popular demand
Bro Code ok thx
Bro Code I don’t understand his second part of his question. What does he mean by can you add one that has to do with OOP?
@girl中国 a Python project that uses Object-Oriented Programming
@@BroCodez no no no , no python, stay in Java LOL
Thank you so much!
❤
Nice
Suporting to keep the channel running
Thanks
Frrr thx
Thank you very much 💕;)
nice video man
thanks bro
dude i saw you subscribed to me.
crazy thing is i have a java exam on tuesday! im really bad at it but i hope i make it.
good luck dude
Nice work
helpful ! thanks
Hi!
does this functions works as coolDown in games? (for skills, events...)
thank you bro .
hey this timer Task I used to update data in database....that through null point exception......you have any soluntion share me please.
Brooooooooo
Ly bro 11
great video but I guess useless for my specific project ;P
haha well you'll know for future projects
Thanks bro !!
Happy New Year !
thanks!
which software are u using ??
Eclipse IDE, I'm using dark theme
U deserve more views :(
thanks cutie
How will I make it to execute every day by midnight
aaaannnd THANK YOUUUUU
what music did you use at the beginning of the video and in the intro?
darude sandstorm
@@BillboMC its been a year and idk why i made this comment hahaha
My birthday is 20th of june
10
1
6
3
8
4
Support
2
5
lol
You literally just subed to my channel with 0 Subs and 0 Videos. Do I know you? XD
I dont think i ever stumbled across one of your Videos.
Why do you know me and where did you find me? XD
I have no idea. Probably from one of a few Learn Java in X minutes videos
@@BroCodez Well, time to change your password. XD I didn't watch these kind of videos. I dont even Programm in java. I just do a little Visual Basic and Mcfunctions. XD
85th. Thank you, ma Bro Sensei
hi
9
This has been deprecated :)
7