View RSS Feed

My Java Tips

  1. Taking inputs from users

    by , 11-08-2011 at 07:28 PM (My Java Tips)
    There are a number of ways to take input from user in Java.
    Following code sample helps you in taking input as a character, as a stream and from GUI.
    Required Packages: import and javax.swing packages.

    Java Code:
    // reading character from user
    char a = (char);
    System.out.println("Character read is: " + a);
    // taking input from GUI
    String input = JOptionPane.showInputDialog("What is your name?");