String Basics
Completed
Read a word. Print its length, first character, last character and the word in upper case.
Input
One word.
Output
Four lines.
Example
Input
java
Output
4 j a JAVA
Editor
Java
Hints
length() is a method, so it needs parentheses.
Indexes go from 0 to length() - 1.
Solution explanation
charAt(i) returns a single char; strings themselves never change.
Show solution
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String w = sc.next();
System.out.println(w.length());
System.out.println(w.charAt(0));
System.out.println(w.charAt(w.length() - 1));
System.out.println(w.toUpperCase());
}
}