By GokiSoft.com|
20:47 30/01/2023|
Java Basic
[Source Code] Cài đặt môi trường & Kiến thức căn bản Java - C2206L
#Main.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
*/
package com.gokisoft;
import java.util.Scanner;
/**
*
* @author diepvan
*/
public class Main {
static enum LIGHT_STATUS {ON, OFF};
public static void main(String[] args) {
System.out.println("Hello World!");
int x, y;
float t;
double d;
char c;
String s1, s2;
x = 10;
y = 6;
t = 5.6F;
d = 6.6;
c = 'A';
s1 = "Sinh vien Aptech";
System.out.println(s1);
System.out.println("s1 = " + s1);
System.out.println("x = " + x + ", y = " + y);
System.out.format("x = %d, y = %d, s1 = %s", x, y, s1);
//B1. Khai bao doi tuong nhap du lieu
Scanner scan = new Scanner(System.in);
//Nhap du lieu tu ban phim
System.out.println("\nNhap x = ");
// x = scan.nextInt();
//scan.nextLine() -> nhap vao 1 String abc
//Integer.parseInt(abc) -> chuyen String -> int
x = Integer.parseInt(scan.nextLine());
System.out.println("Nhap y = ");
// y = scan.nextInt();
y = Integer.parseInt(scan.nextLine());
System.out.format("x = %d, y = %d, s1 = %s", x, y, s1);
System.out.println("Nhap s1 = ");
s1 = scan.nextLine();
System.out.println("s1 = " + s1);
final int tt = 10;
// tt = 12;
//Bong den -> trang thai -> ON / OFF
boolean status = true;//false
int status1 = 1;//1: ON, 0: OFF
LIGHT_STATUS st = LIGHT_STATUS.ON;
//0: pending, 1: approved, 2: ...., ..., 5: cancel
}
}
#Test01.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.gokisoft;
/**
*
* @author diepvan
*/
public class Test01 {
public static void main(String[] args) {
System.out.println("Test01 ...");
}
}
#Test02.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.gokisoft;
/**
*
* @author diepvan
*/
public class Test02 {
public static void main(String[] args) {
System.out.println("Test02 ...");
}
}
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)