Skip to content

Code Examples

Every block has a copy button (top right). Content tabs link, so choosing a language in one group selects it everywhere on the page.

Hello.java
1
2
3
4
5
6
7
public class Hello {
    public static void main(String[] args) {
        for (int i = 1; i <= 3; i++) {
            System.out.println("Hello, " + i);
        }
    }
}
hello.c
1
2
3
4
5
6
7
8
#include <stdio.h>

int main(void) {
    for (int i = 1; i <= 3; i++) {
        printf("Hello, %d\n", i);
    }
    return 0;
}
hello.cpp
1
2
3
4
5
6
7
#include <iostream>

int main() {
    for (int i = 1; i <= 3; ++i) {
        std::cout << "Hello, " << i << '\n';
    }
}
hello.py
for i in range(1, 4):
    print(f"Hello, {i}")
hello.js
1
2
3
for (let i = 1; i <= 3; i++) {
  console.log(`Hello, ${i}`);
}
students.sql
SELECT name, AVG(score) AS average
FROM results
GROUP BY name
HAVING AVG(score) >= 60
ORDER BY average DESC;
hello.sh
#!/usr/bin/env bash
for i in 1 2 3; do
  echo "Hello, $i"
done

Expected output (all but SQL):

Hello, 1
Hello, 2
Hello, 3

Highlighting and annotations

Highlighted line
total = 0
total += 5  # (1)!
print(total)
  1. Annotations explain a line without cluttering the code.

Other formats

site_name: Example
nav:
  - Home: index.md
{ "name": "example", "version": 1 }
const add = (a: number, b: number): number => a + b;

Inline code with a language: print("hi").

Troubleshooting pattern

Error

SyntaxError: invalid syntax

Check for a missing colon or unmatched bracket on the line above.