“Dapatkan input di Java” Kode Jawaban

Input Java

Scanner in = new Scanner(System.in);
      System.out.print("Please enter hour 1: ");
      int hour1 = in.nextInt();
      System.out.print("Please enter hour 2: ");
      int hour2 = in.nextInt();
      System.out.print("Please enter minute 1: ");
      int min1 = in.nextInt();
      System.out.print("Please enter minute 2: ");
      int min2 = in.nextInt();
Sid Potti

Java mendapatkan input

Scanner sc = new Scanner(System.in);
String s = sc.next();
int n = sc.nextInt();
double d = sc.nextDouble();
float f = sc.nextFloat();

// more fast way
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine(); // read line
int c = br.read();        // read single char
Super Stoat

Input Java

import java.util.Scanner;

class Input {
    public static void main(String[] args) {
    	
        Scanner input = new Scanner(System.in);
    	
        System.out.print("Enter an integer: ");
        int number = input.nextInt();
        System.out.println("You entered " + number);

        // closing the scanner object
        input.close();
    }
}
Purple Team

Dapatkan input di Java

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Sample {

    public static void main(String[] args) {
        BufferedReader datain = new BufferedReader(new InputStreamReader(System.in));
        String name = "";
        System.out.print("Enter your name:");
        try {
            name = datain.readLine();
        } catch (IOException e) {
            System.out.print("Error");

        }
        System.out.println("Hello! " + name + "!");
    }

}
Fernandez, Jasmine M.

Java mendapatkan input


import java.util.Scanner; 
//...
Scanner scan = new Scanner(System.in);
String s = scan.next();
int i = scan.nextInt();

Ugliest Unicorn

Jawaban yang mirip dengan “Dapatkan input di Java”

Pertanyaan yang mirip dengan “Dapatkan input di Java”

Lebih banyak jawaban terkait untuk “Dapatkan input di Java” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya