ทรัพยากรอยรั่ว:ข้อมูลไม่เคยปิด

รหัสตัวอย่าง

0
0

resurce อยรั่วของจาวา

public void readShapeData() throws IOException {
    Scanner in = new Scanner(System.in);
    try {
        System.out.println("Enter the width of the Rectangle: ");
        width = in.nextDouble();
        System.out.println("Enter the height of the Rectangle: ");
        height = in.nextDouble();
    } finally {
        in.close();
    }
}
0
0

ทรัพยากรอยรั่ว:'นำเข้าข้อมูล'คือไม่เคยปิด

// You need to close Scanner. It can run, but there will be resource problems in the future.

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

// Change to
public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    try{
        String txt = input.nextLine();
        System.out.println("input "+txt);
    } finally {
        input.close();
    }            
}

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังหน้ากับตัวอย่างอยู่ในหมวดหมู่