/    Sign up×
Community /Pin to ProfileBookmark

Keyboard input

I am working on a school project, make a yahtzee game in Java.
Here for i need to use input from the keyboard.
I managed to get some keyboard input/output program working.
But I still fail to use this in a further program.
here is the code i found.

[code]
import java.io.*;

public class InvoerToetsenbord
{
public static void main ( String [] args)
{
BufferedReader toetsenbord = new Buffered Reader ( new InputStreamReader ( System.in ) );
int i = 0;
double d = 0.0;
System.out.println ( “Toetsenbord gemaakt” );

try
{
String s = toetsenbord.readLine();
System.out.println(“U wrote ” + s);
}
catch ( IOException ioe )
{
System.out.println ( “Fout bij inlezen” );
}
}

}[/code]

I think the following code declares where a program starts instead of a normal method is being declared.

[code]public static void main(String[] args)[/code]

Am i right with this, or what does it means?
Gonna try some more, see if i can fix it before i get an answer here =)

to post a comment
Java

3 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliOct 10.2006 — yes thats exactly it means, the program starts from this method. Second to get continuous input from user, you will require to run your code in a loop..
Copy linkTweet thisAlerts:
@acemoauthorOct 10.2006 — Its obvious u need a loop to get a continuous input.

That was the whole problem we had cuz we are at captor 5 and at captor 12 it tells u how to get user input.

so we had to copy the script from captor 12 and try to adjust it to work for us.

When I noticed the public static void main ( String [] args) is for starting the program, it was alot more easy to do.

We managed to get a continuous input and we can process this input aswell.

We should have finished the application tomorrow.
Copy linkTweet thisAlerts:
@agent_x91Oct 11.2006 — Good luck. By the way this section of code:


catch ( IOException ioe )

{

System.out.println ( "Fout bij inlezen" );

}

[/QUOTE]


Generally it is good practice to use [I]ioe.printStackTrace();[/I] here, so that it is clear exactly where the exception originated, although it's not actually necessary.
×

Success!

Help @acemo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...