วิชาภาษาจาวา (java)

รับค่าจากแป้นพิมพ์ ด้วยภาษาจาวา (java)

ในการรับค่าจากแป้นพิมพ์นั้นถือเป็นเรื่องที่มีความสำคัญมาก ๆ ของการเรียนรู้ในเรื่องของภาษาจาวาเลย เนื่องมาจากมันสามารถนำไปต่อยอดทำโปรเจคหรือชิ้นงานอื่น ๆ ได้หลากหลายมาก ๆ 

การรับค่าจากแป้นพิมพ์ ด้วยภาษาจาวา (java)

 

//มีการ import คำสั่งรับค่าจากเครื่องปริ้นโดยการใช้ Scanner
import java.util.Scanner;
class Inputdata{
public static void main(String []args){
//มีการประกาศใช้งาน class ตั้งชื่อว่า new
Scanner sc=new Scanner(System.in);
System.out.println("กรอกชื่อ = ");
//กรณีรับค่าข้อมูลที่เป็น String 
String name=sc.nextLine();
System.out.println("อายุ = ");
//กรณีรับค่าข้อมูลที่เป็น int 
int aeg=sc.nextInt();
System.out.println("กรุณาตรวจสอบข้อมูลของท่าน"+name+aeg );
}
}

ผลที่ได้จากการทำงานของคำสั่ง

กรอกชื่อ = wuttichai
อายุ = 26
กรุณาตรวจสอบข้อมูลของท่านwuttichai26

slot gacor hari ini slot qris slot gacor maxwin slot online slot gacor gampang menang slot gacor hari ini slot online slot slot slot guci777 guci777 fafatogel fafatogel fafatogel fafatogel agen138 slot agen138 slot data hk bola slot bolaslot99 bola slot agen138 link alternatif koin138 link alternatif agen138 slot ag138 slot slot gacor slot thailand