Switch to full style
General Java code examples
Post a reply

read from command line

Thu Jan 29, 2009 3:10 pm

Read from command line :
This code allow you to read from console in Java.

Code:
import java.util.Scanner;

/**
*
* @author SAMI
*/

public class Main {

    public static void main(String[] args) {
        // TODO code application logic here
         Scanner  LineInput=new Scanner(System.in);

         
       
        System.out.println("Please enter your name : ");
         String name=LineInput.nextLine();
         System.out.println("Please enter your age : ");
         int Age=LineInput.nextInt();
         System.out.println("Dear member : "+name);
         System.out.println("Your age is : "+Age);
         
       
       
    }

}




Post a reply
  Related Posts  to : read from command line
 c program - command line prompt - need help     -  
 Command Line Parser Code Using C++     -  
 How to implement Command Line Parser in C++ Code     -  
 program to run shell command line functions     -  
 Command line chat (client and server)     -  
 Reading a File Line by Line in php     -  
 Line Translation 2D     -  
 Line Rotation 2D     -  
 start a new line in html     -  
 Line Styles in java     -  

Topic Tags

Java Files and I/O