Language: C++

//
// Write a program which reads an integer x and print it as is.
// Note that multiple datasets are given for this problem.
//

import java.io.BufferedReader;
import java.io.InputStreamReader;

interface Aggregate {
	public abstract Iterator createIterator();
}

interface Iterator {
	public abstract boolean hasNext();
	public abstract Object next();
}

 class TestCases implements Aggregate {
	private int[] data;
	private int last = 0;
	
	public TestCases(int max) {
		data = new int[max];
	}
	
	public int getDataAt(int index) {
		return data[index];
	}
	
	public void appendData(int data) {
		this.data[last] = data;
		last++;
	}
	
	public int getLength() {
		return last;
	}
	
	public Iterator createIterator() {
		return new TestCasesIterator(this);
	}
}
 
 class TestCasesIterator implements Iterator {
	 private TestCases testCases;
	 private int index = 0;
	 
	 public TestCasesIterator(TestCases testCases) {
		 this.testCases = testCases;
		 this.index = 0;
	 }
	 
	 public boolean hasNext() {
		 if (index < testCases.getLength()) {
			 return true;
		 } else {
			 return false;
		 }
	 }
	 
	 public Object next() {
		 Integer data = testCases.getDataAt(index);
		 index++;
		 return data;
	 }
}

class PrintTestCases {
	private static PrintTestCases printTestCase = new PrintTestCases();
	private TestCases testCase;
	
	private PrintTestCases() {
		testCase = new TestCases(10000);
	}
	
	public static PrintTestCases getInstance() {
		return printTestCase;
	}
	
	public void read() {
		try {
			BufferedReader br =
					new BufferedReader(new InputStreamReader(System.in));
			String line = "";
			while (null != (line = br.readLine())) {
				int data = Integer.parseInt(line);
				if (0 == data)
					break;
				testCase.appendData(data);
			}
		} catch (Exception e) {
			System.exit(1);
		}
	}
	
	public void write() {
		Iterator it = testCase.createIterator();
		int cnt = 1;
		
		while (it.hasNext()) {
			System.out.println("Case " + (cnt++) + ": " + it.next());
		}
	}
}

public class Main {
	public static void main(String[] args) {
		PrintTestCases test = PrintTestCases.getInstance();
		test.read();
		test.write();
	}

}

Compiler output:
a.cc:6:1: error: 'import' does not name a type
    6 | import java.io.BufferedReader;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
    7 | import java.io.InputStreamReader;
      | ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: 'interface' does not name a type
    9 | interface Aggregate {
      | ^~~~~~~~~
a.cc:13:1: error: 'interface' does not name a type
   13 | interface Iterator {
      | ^~~~~~~~~
a.cc:18:29: error: expected initializer before 'Aggregate'
   18 |  class TestCases implements Aggregate {
      |                             ^~~~~~~~~
a.cc:44:37: error: expected initializer before 'Iterator'
   44 |  class TestCasesIterator implements Iterator {
      |                                     ^~~~~~~~
a.cc:69:16: error: expected ':' before 'static'
   69 |         private static PrintTestCases printTestCase = new PrintTestCases();
      |                ^~~~~~~
      |                :
a.cc:69:74: error: invalid use of incomplete type 'class PrintTestCases'
   69 |         private static PrintTestCases printTestCase = new PrintTestCases();
      |                                                                          ^
a.cc:68:7: note: definition of 'class PrintTestCases' is not complete until the closing brace
   68 | class PrintTestCases {
      |       ^~~~~~~~~~~~~~
a.cc:69:39: error: in-class initialization of static data member 'PrintTestCases PrintTestCases::printTestCase' of incomplete type
   69 |         private static PrintTestCases printTestCase = new PrintTestCases();
      |                                       ^~~~~~~~~~~~~
a.cc:69:39: error: 'PrintTestCases PrintTestCases::printTestCase' has incomplete type
a.cc:70:16: error: expected ':' before 'TestCases'
   70 |         private TestCases testCase;
      |                ^~~~~~~~~~
      |                :
a.cc:70:27: error: field 'testCase' has incomplete type 'TestCases'
   70 |         private TestCases testCase;
      |                           ^~~~~~~~
a.cc:18:8: note: forward declaration of 'class TestCases'
   18 |  class TestCases implements Aggregate {
      |        ^~~~~~~~~
a.cc:72:16: error: expected ':' before 'PrintTestCases'
   72 |         private PrintTestCases() {
      |                ^~~~~~~~~~~~~~~
      |                :
a.cc:76:15: error: expected ':' before 'static'
   76 |         public static PrintTestCases getInstance() {
      |               ^~~~~~~
      |               :
a.cc:80:15: error: expected ':' before 'void'
   80 |         public void read() {
      |               ^~~~~
      |               :
a.cc:96:15: error: expected ':' before 'void'
   96 |         public void write() {
      |               ^~~~~
      |               :
a.cc:104:2: error: expected ';' after class definition
  104 | }
      |  ^
      |  ;
a.cc: In constructor 'PrintTestCases::PrintTestCases()':
a.cc:73:47: error: invalid use of incomplete type 'class TestCases'
   73 |                 testCase = new TestCases(10000);
      |                                               ^
a.cc:18:8: note: forward declaration of 'class TestCases'
   18 |  class TestCases implements Aggregate {
      |        ^~~~~~~~~
a.cc: In member function 'void PrintTestCases::read()':
a.cc:82:25: error: 'BufferedReader' was not declared in this scope
   82 |                         BufferedReader br =
      |                         ^~~~~~~~~~~~~~
a.cc:84:25: error: 'String' was not declared in this scope
   84 |                         String line = "";
      |                         ^~~~~~
a.cc:85:32: error: 'null' was not declared in this scope
   85 |                         while (null != (line = br.readLine())) {
      |                                ^~~~
a.cc:85:41: error: 'line' was not declared in this scope
   85 |                         while (null != (line = br.readLine())) {
      |                                         ^~~~
a.cc:85:48: error: 'br' was not declared in this scope
   85 |                         while (null != (line = br.readLine())) {
      |                                                ^~
a.cc:86:44: error: 'Integer' was not declared in this scope
   86 |                                 int data = Integer.parseInt(line);
      |                                            ^~~~~~~
a.cc:91:26: error: 'Exception' does not name a type
   91 |                 } catch (Exception e) {
      |                          ^~~~~~~~~
a.cc:92:25: error: 'System' was not declared in this scope
   92 |                         System.exit(1);
      |                         ^~~~~~
a.cc: In member function 'void PrintTestCases::write()':
a.cc:97:17: error: 'Iterator' was not declared in this scope
   97 |                 Iterator it = testCase.createIterator();
      |                 ^~~~~~~~
a.cc:100:24: error: 'it' was not declared in this scope; did you mean 'int'?
  100 |                 while (it.hasNext()) {
      |                        ^~
      |                        int
a.cc:101:25: error: 'System' was not declared in this scope
  101 |                         System.out.println("Case " + (cnt++) + ": " + it.next());
      |                         ^~~~~~
a.cc:101:62: error: invalid operands of types 'const char*' and 'const char [3]' to binary 'operator+'
  101 |                         System.out.println("Case " + (cnt++) + ": " + it.next());
      |                                            ~~~~~~~~~~~~~~~~~ ^ ~~~~
      |                                                    |           |
      |                                                    const char* const char [3]
a.cc: At global scope:
a.cc:106:1: error: expected unqualified-id before 'public'
  106 | public class Main {
      | ^~~~~~