online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
public class Main { public static void main(String []args){ ComponentVisitor<SerializedComponent> serializer = new ComponentSerializer(); Component componentA = new ComponentA(); SerializedComponent serializedA = componentA.accept(serializer); System.out.println(serializedA); Component component = new ComponentB(); SerializedComponent serializedB = component.accept(serializer); System.out.println(serializedB); } static interface Component { public <V> V accept(ComponentVisitor<V> visitor); } static class ComponentA implements Component { public <V> V accept(ComponentVisitor<V> visitor) { return visitor.visit(this); } } static class ComponentB implements Component { public <V> V accept(ComponentVisitor<V> visitor) { return visitor.visit(this); } } static interface SerializedComponent {} static class SerializedComponentA implements SerializedComponent { } static class SerializedComponentB implements SerializedComponent { } static interface ComponentVisitor<V> { public V visit(ComponentA component); public V visit(ComponentB component); } static class ComponentSerializer implements ComponentVisitor<SerializedComponent> { public SerializedComponent visit(ComponentA component) { return new SerializedComponentA(); } public SerializedComponent visit(ComponentB component) { return new SerializedComponentB(); } } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue