How do I get the last character of a string?

前端 未结 11 2218
遥遥无期
遥遥无期 2020-12-02 07:59

How do I get the last character of a string?

public class Main {
    public static void main(String[] args)  {
        String s = "test string";
            


        
11条回答
  •  隐瞒了意图╮
    2020-12-02 08:34

    public String lastChars(String a) {
    if(a.length()>=1{
    String str1 =a.substring(b.length()-1);
    }
    return str1;
    }
    

提交回复
热议问题