Do you have a getChar() in java - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Do you have a getChar() in java

RibbletonRibbleton Posts: 152Member


just typed :

public class Welcome1 {
public static void main( String args[] )
{
System.out.println( "Welcome to Java Programming!" );
}
}

but it ran right through and didn't allow me to see the result. Do you have a getchar() function in java like you do in C++ ?

thanks for any help

*Ribbleton*


Comments

  • SouldrinkerSouldrinker Posts: 143Member
    :
    :
    : just typed :
    :
    : public class Welcome1 {
    : public static void main( String args[] )
    : {
    : System.out.println( "Welcome to Java Programming!" );
    : }
    : }
    :
    : but it ran right through and didn't allow me to see the result. Do you have a getchar() function in java like you do in C++ ?
    :
    : thanks for any help
    :
    : *Ribbleton*
    :
    :
    :

    Java is a completely object orientated language, I don't think, that there is some way to "stop" the code, until a char is entered. This would work against the basic concept of the language.

  • arb123arb123 Posts: 696Member
    [code]
    import java.io.IOException;

    public class PressEnterToContinue {

    public static void pressEnterToContinue() {
    System.out.println("Press ENTER to continue...");
    try {
    System.in.read();
    while (System.in.available() > 0)
    System.in.read(); //flush the buffer
    } catch (IOException e) {
    e.printStackTrace();
    }
    }

    public static void main(String[] args) {
    pressEnterToContinue();
    }

    }
    [/code]

    ---------------------------------
    [size=1]HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]

Sign In or Register to comment.