Remove first word from a string in Java

前端 未结 9 1986
天涯浪人
天涯浪人 2020-12-29 12:20

What\'s the best way to remove the first word from a string in Java?

If I have

String originalString = \"This is a string\";

I want to r

9条回答
  •  悲&欢浪女
    2020-12-29 12:50

    You can check where is the first space character and seperate string.

    String full = "Sample Text";
    String cut;
    int pointToCut = full.indexOf( ' ');
    
    if ( offset > -1)
    {
      cut = full.substring( space + 1);
    }
    

提交回复
热议问题