Example usage for java.lang System in

List of usage examples for java.lang System in

Introduction

In this page you can find the example usage for java.lang System in.

Prototype

InputStream in

To view the source code for java.lang System in.

Click Source Link

Document

The "standard" input stream.

Usage

From source file:Main.java

public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    System.out.println("Please enter elements...");
    char[] a = sc.next().toCharArray();
    System.out.println("Array elements are : ");
    for (int i = 0; i < a.length; i++)
        System.out.println(a[i]);
}

From source file:Main.java

public static void main(String[] args) {
    Scanner scanInput = new Scanner(System.in);
    String input = scanInput.nextLine();
    System.out.println("The input is : " + input);
}

From source file:Main.java

public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    String confirm = "y";

    do {/*from   ww w .j  a  va2 s .  c  om*/
        System.out.println("Welcome to Java Programming!");
        System.out.println("Print Again? (y/n)");
        confirm = input.nextLine();
    } while (confirm.equalsIgnoreCase("y"));
}

From source file:Main.java

public static void main(String[] args) {

    Scanner input = new Scanner(System.in);
    String answer = input.nextLine();

    if ("yes".equals(answer)) {
        System.out.println("Yea!");
    } else {/* www. java  2s  . c o  m*/
        System.out.println("No :(");
    }
}

From source file:MainClass.java

public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);
    String s = scanner.next();/*from  w  w w . j a v  a2  s. c om*/

    System.out.println(s);
}

From source file:Main.java

public static void main(String[] args) {

    try {/* w w w. ja v  a 2  s. c o m*/
        char c = (char) System.in.read();
        while (c != '\r') {
            System.out.println(c);
            c = (char) System.in.read();
        }
    } catch (IOException e) {
    }

}

From source file:Main.java

public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    System.out.print("Username: ");
    String username = scanner.nextLine();

    System.out.print("Password: ");
    String password = scanner.nextLine();

    System.out.print("What is 2 + 2: ");
    int result = scanner.nextInt();

    if (username.equals("admin") && password.equals("secret") && result == 4) {
        System.out.println("Welcome");
    } else {/* ww w.  j a v a2 s  .  co  m*/
        System.out.println("Invalid username or password!");
    }
}

From source file:MainClass.java

public static void main(String args[]) {
    Scanner conin = new Scanner(System.in);

    int count = 0;

    System.out.println("Enter numbers to average.");

    while (conin.hasNext()) {
        if (conin.hasNextDouble()) {
            System.out.println(conin.nextDouble());
            count++;/*from  w  w w .j  a v  a 2s  . c om*/
        }
        if (count == 3) {
            System.exit(0);

        }
    }

}

From source file:MainClass.java

public static void main(String args[]) {
    Scanner input = new Scanner(System.in);

    int x;//  ww w .ja va  2s .  c  om
    int y;
    int z;
    int result;

    System.out.print("Enter first integer: ");
    x = input.nextInt();

    System.out.print("Enter second integer: ");
    y = input.nextInt();

    System.out.print("Enter third integer: ");
    z = input.nextInt();

    result = x * y * z;

    System.out.printf("Product is %d\n", result);

}

From source file:Main.java

public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    String userName;// www  .j a  v  a 2  s  . c  o m
    System.out.println("Enter your email address: ");
    userName = scn.findInLine(Pattern.compile("[a-z]+"));

    System.out.println(userName);
}