How do I perform console input?

edited September 2014 in How To...

I'm teaching a high school computer science class, using Processing. I see the print and println functions for console output, but don't see the corresponding input functions. Where is readln or its equivalent?



  • edited September 2014

    Processing's IDE's console doesn't accept keyboard input! :|
    We gotta compile the sketch w/ CTRL+E and run directly from console: :-B

    // how-do-i-perform-console-input
    // java-how-to-get-input-from-system-console
    import java.util.Scanner;
    String name;
    byte age;
    Scanner in = new Scanner(;
    println("Type in your name...");
    name = in.nextLine();
    println("Type in your age...");
    age = in.nextByte();
    println("\nName: \t" + name);
    println("Age: \t" + age);
  • Alternatively, the standard way of getting user input in Processing is to use keyPressed() and similar functions.

Sign In or Register to comment.