- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrors.java
More file actions
Latest commit
23 lines (19 loc) · 619 Bytes
/
Copy pathErrors.java
File metadata and controls
23 lines (19 loc) · 619 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
importjava.util.Scanner;
publicclassErrors {
publicstaticvoidmain(String[] args) {
// SYNTAX ERROR DEMO
inta = 0// Error: no semicolon!
b = 8; // Error: b not declared!
// LOGICAL ERROR DEMO
// Write a program to print all prime numbers between 1 to 10
System.out.println(2);
for (inti=1; i<5; i++){
System.out.println(2*i+1);
}
// RUNTIME ERROR
intk;
Scannersc = newScanner(System.in);
k = sc.nextInt();
System.out.println("Integer part of 1000 divided by k is "+ 1000/k);
}
}