Color theme
0 day streak0 XPP1
JavaLearn mode
MISSION 1 OF 3

Make an exhibit code

0 XP earned
Java track: IntermediateMission: BeginnerString slicingZero-based indexesWhitespace trimming
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.

x
0 / 6 challenges
LEARN THE CONCEPT

Understand it, then try it.

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.

Main.java
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.

Track the values line by line. Predict the result before running this example in your own editor.