How to insert code in topic?

[java]
@Autowired
private ARI ari;
[/java]

Discourse uses Markdown for the most part.

Jeff has a good post in the meta discussion of Discourse to explain all the various formatting things that are supported.