Learn
String Methods
charAt()

The charAt() method returns the character located at a String‘s specified index.

For example:

String str = "qwer"; System.out.println(str.charAt(2));

It would output e because that’s what’s at index 2. (Once again, indices start with 0.)

Suppose we try return the character located at index 4, it would produce an error because index 4 is out of str‘s range.

Instructions

1.

In Initials.java, add your first name and last name.

2.

Print out the initials of the firstName and lastName.

Folder Icon

Take this course for free

Already have an account?