What is the best way to get the first letter from a string in Java, returned as a string of length 1?

前端 未结 5 1614
自闭症患者
自闭症患者 2020-12-08 08:43

Assume the following:

String example      = \"something\";
String firstLetter  = \"\";

Are there d

5条回答
  •  悲&欢浪女
    2020-12-08 09:38

    String whole = "something";
    String first = whole.substring(0, 1);
    System.out.println(first);
    

提交回复
热议问题