Make an exhibit code
Before you start this intermediate track
Variables, methods, and typed collections. The lessons use constructors, fields, and maps.
Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.
Predict the result.
What exhibit code and cleaned-title length are printed?
public class Main { public static void main(String[] args) { String raw = " ORBIT "; String title = raw.strip(); String code = title.substring(0, 3); System.out.println(code + " (" + title.length() + ")"); }}Each example is a complete Java 11+ source file named Main.java. Compile with javac Main.java and run with java Main. Each mission is independent.
Review the lesson
String methods return useful views or transformed versions of text. strip removes surrounding whitespace, and substring selects characters between a starting index and an exclusive ending index. Java indexes begin at zero, so indexes zero through two form a three-character code. length reports the number of characters in this ASCII title.