Skip to content

Commit f3dd384

Browse files
committed
1 parent d60c427 commit f3dd384

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/standard_input/other_types.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,16 @@ void main() {
2121
char grade = Character.parseCharacter(gradeString);
2222
IO.println("You have a " + grade + " in the class.");
2323
}
24+
```
25+
26+
For characters specifically you can get the first character of a `String` with `.charAt(0)`,
27+
but you might also want to check that said `String` is only one character long. Each type
28+
will be special.
29+
30+
```java,no_run
31+
void main() {
32+
String gradeString = IO.readln("What is your letter grade? ");
33+
char grade = gradeString.charAt(0);
34+
IO.println("You have a " + grade + " in the class.");
35+
}
2436
```

0 commit comments

Comments
 (0)