import java.util.ArrayDeque; /** * Arithmetique */ public class Infixe { public static void main(String[] args) { ArrayDeque> pile = new ArrayDeque<>(); for (String arg : args) { try { Integer.parseInt(arg); pile.addFirst(new Node(arg)); } catch (NumberFormatException e) { if (pile.size() < 2) { System.err.println("Invalid stack size."); return; } Node n2 = pile.pollFirst(); Node n1 = pile.pollFirst(); Node n3 = new Node(arg); n3.addSubNode(n1); n3.addSubNode(n2); pile.addFirst(n3); } } System.out.println(pile.pollFirst().showNode()); } }