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); } }
@sreeshakv5405
2 жыл бұрын
Thanks
@joyceasante8292
Жыл бұрын
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); } }
@ramonoseiakoto2627
2 жыл бұрын
The language is beautiful, your voice is clear and your teaching is fantastic keep it up bro
@zachfornero9371
Жыл бұрын
You are seriously amazing dude your tutorials alone have taught me Java
@ShiroVK870
4 жыл бұрын
Loving the java tutos 👍
@shaynazoedeguzman7418
2 жыл бұрын
Your tutorial is amazing! The best!
@guilhermeerafaeldourado247
2 жыл бұрын
my man u are a true legend
@smburhan6323
Жыл бұрын
Well Im a Fellow Bro 🤜🤛
@eugenezuev7349
2 ай бұрын
the king of tutors
@cavemutt
2 ай бұрын
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!!!
@tedd_y3423
2 жыл бұрын
tysm! I was looking for a way to run code every 10 milliseconds while something else is running and this helped me a lot.
@vuchinh9989
3 жыл бұрын
Bestt tutor with humour. Thanks alot!
@matthewbrightman3398
3 жыл бұрын
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 :)
@redwaroon6880
3 жыл бұрын
Liked Commented Subscribed
@jaysonp9426
2 жыл бұрын
Thank you! This solution was surprisingly hard to find on Google/KZitem
@flameyosflow_4834
Жыл бұрын
Really nice video. I didn't see any documentation on Timer and I found your video Really helped me understand everything.
@dougrattmann5791
Жыл бұрын
You make the best java tutorials.
@szaronaangel7725
11 ай бұрын
❤
@84_mostafaabbas88
3 жыл бұрын
perfect examples thanks a lot
@emanuelitalo5073
Жыл бұрын
Im brazilian programer and you helped me a lot, thanks bro
@percivalgebashe4376
Жыл бұрын
nICE
@raviratnakar3803
3 жыл бұрын
the greatest outro ever!
@Makariush
Жыл бұрын
Best Java tutorial out there, thanks a lot Bro!
@kimojumamil6121
3 жыл бұрын
This helped me a lot :) Thank you
@sreeshakv5405
2 жыл бұрын
Super
@kemann3815
2 жыл бұрын
Thanks an unimaginable amount, bro.
@tulichakraborty4645
3 жыл бұрын
This is fun..like it👍
@girl6994
4 жыл бұрын
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.
@sacredscrollshub
2 ай бұрын
Nice
@ejschoolaccount8299
11 ай бұрын
Love it
@Monster33336
3 жыл бұрын
Very few Americans nowdays do Java because it's so hard, so thank you.
@ryan2-518
3 жыл бұрын
Lol
@nawfalnjm5699
3 жыл бұрын
thanks . congratulations on 100k subscriber !
@efecantepe3990
3 жыл бұрын
Nice video thank you.
@mudzingwajonah7378
3 жыл бұрын
Sir I love your videos.
@coolgolucool
Жыл бұрын
very helpful thank u
@frattekin1843
3 жыл бұрын
thank you bro very helpfull
@sergeyb6071
4 жыл бұрын
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. 🤩
@BroCodez
4 жыл бұрын
That's a Dungeons & Dragons map generator for a hobby of mine, but a Google Maps program would be a fun project
@redaboukdir5678
2 жыл бұрын
@@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.
@Heomi9905
3 жыл бұрын
Thank you so much!
@carloslozan856
2 жыл бұрын
Suporting to keep the channel running
@MrLoser-ks2xn
2 жыл бұрын
Thanks
@omanouras
2 жыл бұрын
Brooooooooo
@MrLoser-ks2xn
Жыл бұрын
@SsjTestoKellerWaerter
Жыл бұрын
Frrr thx
@marioshusband3700
4 жыл бұрын
can you make videos on python projects? if you do, can you add one that has to do with object-oriented programming?
@BroCodez
4 жыл бұрын
I'll be switching back to Python soon. I wanted to add some more Java videos first due to popular demand
@marioshusband3700
4 жыл бұрын
Bro Code ok thx
@girl6994
4 жыл бұрын
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?
@BroCodez
4 жыл бұрын
@girl中国 a Python project that uses Object-Oriented Programming
@angelcastineira2561
4 жыл бұрын
@@BroCodez no no no , no python, stay in Java LOL
@user-je3jj6fu7y
2 жыл бұрын
Nice work
@ibrahimylmaz8378
2 жыл бұрын
thanks bro
@manuelgonzalezpalafox2627
Жыл бұрын
Ly bro 11
@changeme1832
2 жыл бұрын
Thank you very much 💕;)
@shashwathsk6880
3 жыл бұрын
nice video man
@tonyadji2408
2 жыл бұрын
helpful ! thanks
@siavashnourmohammadi9189
2 жыл бұрын
thank you bro .
@generalviewer8347
4 жыл бұрын
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.
@BroCodez
4 жыл бұрын
good luck dude
@sadasd7518
3 жыл бұрын
Thanks bro !!
@developerjunior446
3 жыл бұрын
Happy New Year !
@angelcastineira2561
4 жыл бұрын
thanks!
@aryanvashishtharollno.6919
3 жыл бұрын
which software are u using ??
@BroCodez
3 жыл бұрын
Eclipse IDE, I'm using dark theme
@user-hu1lp3hh7u
Жыл бұрын
thanks cutie
@oguzhantopaloglu9442
3 жыл бұрын
great video but I guess useless for my specific project ;P
@BroCodez
3 жыл бұрын
haha well you'll know for future projects
@walassi834
Жыл бұрын
Hi! does this functions works as coolDown in games? (for skills, events...)
@lamias7712
2 жыл бұрын
aaaannnd THANK YOUUUUU
@kishortiruke2695
Жыл бұрын
hey this timer Task I used to update data in database....that through null point exception......you have any soluntion share me please.
@frankvalen2147
3 жыл бұрын
How will I make it to execute every day by midnight
@troddennabcodm9246
3 жыл бұрын
U deserve more views :(
@developerjunior446
3 жыл бұрын
10
@developerjunior446
3 жыл бұрын
6
@developerjunior446
3 жыл бұрын
1
@developerjunior446
3 жыл бұрын
8
@mechanicalpencil1016
3 жыл бұрын
what music did you use at the beginning of the video and in the intro?
@BillboMC
2 жыл бұрын
darude sandstorm
@mechanicalpencil1016
2 жыл бұрын
@@BillboMC its been a year and idk why i made this comment hahaha
@developerjunior446
3 жыл бұрын
3
@rodrigoqteixeira
2 жыл бұрын
My birthday is 20th of june
@developerjunior446
3 жыл бұрын
5
@developerjunior446
3 жыл бұрын
2
@shervin9561
2 жыл бұрын
Support
@zari_723
Жыл бұрын
hi
@developerjunior446
3 жыл бұрын
9
@siamax1
Жыл бұрын
lol
@lightjack0540
4 жыл бұрын
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
4 жыл бұрын
I have no idea. Probably from one of a few Learn Java in X minutes videos
@lightjack0540
4 жыл бұрын
@@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
Пікірлер: 100