class Test { private final int foo; public void setFoo(int bar) { foo = bar; } public Test() { } public static void main (String[] args) { Test qux = new Test(); qux.setFoo(42); System.out.println("did it"); } }
Standard input is empty
Main.java:5: error: cannot assign a value to final variable foo foo = bar; ^ 1 error
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!