Why is my timestop programm illegal? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Why is my timestop programm illegal?

I wanted to build a method that can stop the program for a few seconds, so the user can have breaks between the output that he receives. What is my mistake here? Is it actually possible? public void stopSeconds(long s){ long a = System.getCurrentTimeMillis(); do{ long z = System.getCurrentTimeMillis(); long dif = z-a; long stop= s*1000; }while (dif <= stop); https://code.sololearn.com/cxA03SBLV7sn/?ref=app

26th Nov 2018, 5:11 AM
Mau
Mau - avatar
6 Answers
+ 4
You cannot use functions inside a function. You can either place the method outside the main or convert it to a lambda expression.
26th Nov 2018, 12:30 PM
Seniru
Seniru - avatar
+ 2
It's better to use the sleep method
28th Nov 2018, 4:09 AM
Arunesh Sarker
Arunesh Sarker - avatar
+ 1
Allrigghhht :D Thats interesting!! yeah thanks, i think ill study the new commands then :D
26th Nov 2018, 9:22 AM
Mau
Mau - avatar
+ 1
Interesting fact this feature of having a method inside another is coming to C# but with some limitations.
27th Nov 2018, 9:38 AM
jay
0
Bennett Post So i have to include methods always in other classes?
26th Nov 2018, 6:58 AM
Mau
Mau - avatar
0
I seeeee thanks Bennett Post 😁😁😘
26th Nov 2018, 7:01 AM
Mau
Mau - avatar