How to extract the first letter of the first name and first letter of the last name of a string?

Hello, a username is Michael.Bontont

How can I extract the first letter of the first name (Michael) and first letter of the last name (Bontont)?

There is a problem with the type of argument.

I do not think that String does not have a method named slice in Java.

Have you invented it yourself?

No. I will try to use substring () method.

You had better use String.split(String delimiter) method.

String name="Michael.Bontont"
name.split(0,1)

Getting same error as before

What is the problem?

How to use String method, Split
Groovy - split() (tutorialspoint.com)

How to use String method, Substring
Groovy - subString() (tutorialspoint.com)

Maybe like:
String clientName = "Michael.Bontont"
	
List<String> names = clientName.split("\\.")
StringBuffer sbuf = new StringBuffer()
for (int cnt = 0; cnt < names.size(); cnt++) {

	sbuf.append(names.get(cnt).substring(0,1))
}
	
WebUI.comment("abbreviated name is ${sbuf}")

Here is a problem.

You should carefully read the document that @grylion54 suggested.

@grylion54 Thanks a lot! It works!
names = [Michael, Bontont]
get(0) = Michael - substring(0,1)=M
get(1) = Bontont - substring(0,1)=B