Results 1 to 6 of 6
Thread: Time Intervals In Java Outprint
- 01-10-2012, 02:24 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 28
- Rep Power
- 0
Time Intervals In Java Outprint
Hey Forum Users,
I have a game to make in my class and this is the code
Java Code:
package Samurai;
import java.util.*;
public class Samurai {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String nameofwarrior;
Scanner keyboard = new Scanner (System.in);
System.out.println("Hey The Ol'e Wise Man Wishes to Know your NAME");
nameofwarrior=keyboard.nextLine();
System.out.println("*.**.* YOU ARE THE CHOOSEN ONE "+nameofwarrior+" *.**.* \n DESTINY AWAITS YOU ON YOUR JOURNEY \n CHOOSE YOUR BEGINING HOMETOWN");
}
}
So the question is that how can i have a time interval of outprint between 2 System.out.println("thecomment");
so that 1 print after 2 seconds after printing the other
Last edited by dharav; 01-10-2012 at 02:27 AM.
- 01-10-2012, 02:42 AM #2
Re: Time Intervals In Java Outprint
java.util.Timer / TimerTask
db
edit Or if it's really as simple as the code you posted, Thread#sleep(...)Why do they call it rush hour when nothing moves? - Robin Williams
- 01-10-2012, 03:24 AM #3
Re: Time Intervals In Java Outprint
Java Code:System.out.println ("...") ;// first output try { Thread.sleep(1000); // a simple timer of 1 second (1000 milliseconds) } catch (InterruptedException e) {} System.out.println ("...") ;// second output
- 01-10-2012, 03:32 AM #4
Member
- Join Date
- Dec 2011
- Posts
- 28
- Rep Power
- 0
Re: Time Intervals In Java Outprint
Thank you Cuppa Coffee it worked like a charm and this is my final code
Java Code:
package Samurai;
import java.util.*;
public class Samurai {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String nameofwarrior;
Scanner keyboard = new Scanner (System.in);
System.out.println("Hey The Ol'e Wise Man Wishes to Know your NAME");
nameofwarrior=keyboard.nextLine();
System.out.println("*.**.* YOU ARE THE CHOOSEN ONE "+nameofwarrior+" *.**.* \n DESTINY AWAITS YOU ON YOUR JOURNEY \n CHOOSE YOUR BEGINING HOMETOWN");
try
{
Thread.sleep(1000); // a simple timer of 1 second (1000 milliseconds)
}
catch (InterruptedException e)
{}
System.out.println("You are chooosen TO be the one");
}
}
Thank you Again and the Thread should be closed.
- 01-10-2012, 03:34 AM #5
Member
- Join Date
- Dec 2011
- Posts
- 28
- Rep Power
- 0
Re: Time Intervals In Java Outprint
How do you close the post
- 01-10-2012, 03:35 AM #6
Similar Threads
-
Intervals of Days and Weeks
By jazob in forum New To JavaReplies: 0Last Post: 12-14-2011, 10:55 PM -
Desingn time properties missing at run time - Netbeans
By junaid in forum New To JavaReplies: 3Last Post: 12-07-2011, 07:00 AM -
JAVA Programmers Wanted - Full-Time and Part-Time Positions open
By javatrek2020 in forum Jobs OfferedReplies: 3Last Post: 08-23-2011, 12:46 PM -
Setting unveven intervals in chart range axis
By deeps in forum Advanced JavaReplies: 0Last Post: 03-30-2010, 06:11 AM -
how to change password in regular intervals
By mohan404 in forum Advanced JavaReplies: 4Last Post: 04-08-2008, 11:46 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks