View RSS Feed

Recent Blogs Posts

  1. Taking inputs from users

    by , 11-08-2011 at 06: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 java.io and javax.swing packages.



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