We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Java Static Initializer Block
Java Static Initializer Block
Sort by
recency
|
1314 Discussions
|
Please Login in order to post a comment
import java.io.; import java.util.;
public class Solution {
}
Code samples for Java 8 and 15 don't use static initialisers at all. What's wthe matter with them? Only Java 7 is fine.
import java.io.; import java.util.;
public class Solution { public static void main(String[] args) { int b, h, area; Scanner sc = new Scanner(System.in); b = sc.nextInt(); h = sc.nextInt(); if (b >= 0 && h >= 0){ area = b*h; System.out.println(area); } else { System.out.println("java.lang.Exception: Breadth and height must be positive"); } } }