Chapter 2 · Java
Java: What is Artificial Intelligence?
Run this example
Edit and run the java example
Change the source and run it here. Use the output panel to compare your result with the expected highlights below.
Output
Run the code to see output here.
Java - Six-Axis Profiles and the Review Decision
It prints the same bytes as the Python version: the profiles are fixed data, amounts are rounded half-up with the same helper in both languages, and all formatting uses Locale.ROOT.
How the program is organized
public class AiSystemClassifier {
// Authority comes from the most powerful effect an output may have
record Level(String name, String scale) {} // e.g. ("draft", "5")
static final List<String> ORDER = List.of("display", "suggest", "prepare",
"state_policy", "act_reversible", "act");
// One record per system: the six axes plus effects and controls
record Profile(String name, String field, List<String> method, String family,
List<String> capability, String application,
List<String> effects, List<String> controls) {}
static List<String> check(Profile p) { ... } // category errors and authority rules
static double[] policyCosts(double errorRate) { ... } // none, full, routed
}
Modelling authority as a list of effects, instead of a single ranked enum, keeps the reason for a rating visible: a reviewer can see that the Air Canada profile is rated as a binding statement because of state_policy, and that Copilot sits at draft because its strongest effect is prepare.
In a Spring service the Profile record fits naturally as the payload of an architecture-review endpoint: teams submit a profile with each design, and the same check rules run in CI so that a profile claiming execute authority without an approval step or a rollback fails the build.
Expected output
=== Parts 1 and 2: Five systems on six axes, with consistency checks ===
Gmail spam filtering
field AI: natural language processing
method machine learning
model family neural text classifier (RETVec vectorizer, 2023)
capability classify
application email client
authority execute, reversible; Sheridan-Verplank level 7-8
effects act_reversible
checks consistent
GitHub Copilot inline suggestions
field AI: code generation
method machine learning
model family large language model
capability generate
application code editor
authority draft; Sheridan-Verplank level 5
effects display, prepare
checks consistent
Waymo Driver
field AI: robotics and perception
method machine learning, planning, rules
model family neural networks for perception and prediction
capability perceive, predict, plan, act
application ride-hailing
authority execute; Sheridan-Verplank level 9-10
effects act
checks consistent
Air Canada website chatbot (2022)
field not disclosed
method not disclosed
model family not disclosed
capability answer questions
application airline customer service
authority execute: a statement the company must honour; Sheridan-Verplank level 7
effects display, state_policy
CHECK FAILED customer-facing policy statements bind the company; ground them in the canonical policy or route them to a person
Refund bot (a flawed proposal)
field AI
method prompting
model family Generative AI
capability generate, act
application customer refunds
authority execute; Sheridan-Verplank level 9-10
effects state_policy, act
CHECK FAILED 'Generative AI' is a capability, not a model family
CHECK FAILED irreversible action with no approval step, rollback or operating envelope
CHECK FAILED customer-facing policy statements bind the company; ground them in the canonical policy or route them to a person
=== Part 3: Expected monthly cost of three review policies (C$) ===
100,000 conversations a month; 10% of wrong answers acted on at C$812.02 each; review 1.5 min at C$40/h catching 90%.
error rate no review full review risk-routed cheapest
0.1% 8,120 100,812 12,274 no review
0.5% 40,601 104,060 21,368 risk-routed
1.0% 81,202 108,120 32,737 risk-routed
2.0% 162,404 116,240 55,473 risk-routed
5.0% 406,010 140,601 123,683 risk-routed
8.0% 649,616 164,962 191,892 full review
Full review beats no review above an error rate of 1.37%.
Risk-routed review beats no review above 0.17%, and full review beats risk-routed above 6.16%.