By GokiSoft.com|
11:19 23/09/2021|
Java Advanced
[Share Code] Overview kiến thức - C2009G
- Exception
- CSDL
- Console
- Swing
- File
- text
- binary (Serialization + ObjectInputStream ...)
- Thread
- 2 Thread
- 3 Thread
- Đa ngôn ngữ
- Swing
- Mã hoá -> Cipher -> Buổi sau
=====================================================
1) CSDL + Đa ngôn ngữ
2) CSDL + File + Đa ngôn ngữ
3) CSDL + File + Thread
4) CSDL + Thread
5) CSDL + Cipher
6) Exception + File + Thread
Code:
#HinhHoc.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lesson10;
/**
*
* @author Diep.Tran
*/
public abstract class HinhHoc {
public abstract double tinhDienTich();
public abstract double tinhChuVi();
static public class Abc {
String x, y;
public Abc() {
}
public Abc(String x, String y) {
this.x = x;
this.y = y;
}
public String getX() {
return x;
}
public void setX(String x) {
this.x = x;
}
public String getY() {
return y;
}
public void setY(String y) {
this.y = y;
}
}
}
#HinhTron.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lesson10;
/**
*
* @author Diep.Tran
*/
public class HinhTron extends HinhHoc{
float r;
static int k;
public HinhTron() {
}
public HinhTron(float r) {
this.r = r;
}
@Override
public double tinhDienTich() {
return Math.PI * r * r;
}
@Override
public double tinhChuVi() {
return 2 * Math.PI * r;
}
}
#Main.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lesson10;
/**
*
* @author Diep.Tran
*/
public class Main {
public static void main(String[] args) {
HinhTron hinhTron = new HinhTron(12.6f);
double cv = hinhTron.tinhChuVi();
System.out.println(cv);
HinhTron h1 = new HinhTron();
HinhTron.k = 10;
HinhTron h2 = new HinhTron();
HinhTron.k = 15;
System.out.println("k1 = " + HinhTron.k);
System.out.println("k2 = " + HinhTron.k);
HinhHoc.Abc abc = new HinhHoc.Abc();
abc.setX("10");
//Anonymous class.
HinhHoc h = new HinhHoc() {
double x = 10, y = 100;
@Override
public double tinhDienTich() {
return x * y;
}
@Override
public double tinhChuVi() {
return 2 * (x + y);
}
};
System.out.println(h.tinhChuVi());
}
}
#Test.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lesson10;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Diep.Tran
*/
public class Test {
public static void main(String[] args) throws IOException {
IRunning r1 = () -> {
System.out.println("R1 is running...");
};
r1.onRunning();
IRunning r2 = () -> System.out.println("R1 is running...");
r2.onRunning();
IRunning2 r3 = (String msg) -> {
System.out.println("okok ... " + msg);
};
r3.onRunning("12345");
IRunning2 r4 = (a) -> {
System.out.println("okok ... " + a);
};
r4.onRunning("12345");
List<String> list = new ArrayList<>();
list.add("12313");
list.add("3432");
list.add("sdfds");
list.add("342423");
list.forEach(s -> {
System.out.println(s);
});
FileHandler handler = new FileHandler("data.log");
Logger logger = Logger.getLogger(Test.class.getName());
logger.addHandler(handler);
logger.log(Level.INFO, "test....");
}
static interface IRunning {
void onRunning();
}
@FunctionalInterface
static interface IRunning2 {
void onRunning(String msg);
}
}
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)