nitc: move up the default values of a project from the android platform
[nit.git] / tests / test_jvm / Queue.java
1 package test_jvm;
2
3 import java.util.*;
4
5 class Queue
6 {
7 // function pointer
8 public native void printError( String errorMsg );
9
10 // internal list
11 private LinkedList<String> list;
12
13 public Queue()
14 {
15 list = new LinkedList<String>();
16 }
17
18 public void push( String element )
19 {
20 System.out.print( "From java, pushing " );
21 System.out.print( element );
22 System.out.print( "\n" );
23 list.addLast( element );
24 }
25
26 public String pop() // knows where is native printError
27 {
28 String element;
29
30 try
31 {
32 element = list.removeFirst();
33 }
34 catch ( NoSuchElementException e )
35 {
36 printError( "From java, empty queue." );
37 element = null;
38 throw e;
39 }
40
41 System.out.print( "From java, popping " );
42 System.out.print( element );
43 System.out.print( "\n" );
44
45 return element;
46 }
47 }
48