Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.