import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the values for length, width and depth : ");
System.out.print(" ");
int length = scanner.nextInt();
System.out.print("");
int width = scanner.nextInt();
System.out.print(" ");
int depth = scanner.nextInt();
Box<Integer, Integer, Integer> box = new Box<>(length, width, depth);
box.print();
}
}
class Box<T1, T2, T3> {
private T1 length;
private T2 width;
private T3 depth;
public Box(T1 length, T2 width, T3 depth) {
this.length = length;
this.width = width;
this.depth = depth;
}
public void print() {
System.out.println("Length : " + length);
System.out.println("Width : " + width);
System.out.println("Depth : " + depth);
}
}
class Box<T1, T2, T3> {
private T1 length;
private T2 width;
private T3 depth;
public Box(T1 length, T2 width, T3 depth) {
this.length = length;
this.width = width;
this.depth = depth;
}
public void print() {
System.out.println("Length:" + length);
System.out.println("Width: " + width);
System.out.println("Depth:" + depth);
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter